babel-plugin-proto-to-assign
The proto-to-assign
plugin will transform all __proto__
assignments to a method that will do a shallow copy of
all properties.
This means that the following will work:
var foo = a: 1 ;var bar = b: 2 ;bar__proto__ = foo;bara; // 1barb; // 2
however the following will not:
var foo = a: 1 ;var bar = b: 2 ;bar__proto__ = foo;bara; // 1fooa = 2;bara; // 1 - should be 2 but remember that nothing is bound and it's a straight copy
This is a case that you have to be aware of if you intend to use this plugin.
Example
In
bar__proto__ = foo;
Out
var _defaults = ...; ;
Installation
$ npm install babel-plugin-proto-to-assign
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
$ babel --plugins proto-to-assign script.js
Via Node API
;