项目原始demo,不改动
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Este repositorio está archivado. Puede ver los archivos y clonarlo, pero no puede subir cambios o reportar incidencias ni pedir Pull Requests.
 
 
 
 
xzx 2ec7739298 [Version] V.3.8 hace 4 años
..
lib [Version] V.3.8 hace 4 años
.npmignore [Version] V.3.8 hace 4 años
README.md [Version] V.3.8 hace 4 años
package-lock.json [Version] V.3.8 hace 4 años
package.json [Version] V.3.8 hace 4 años

README.md

babel-plugin-transform-proto-to-assign

This plugin allows Babel to transform all __proto__ assignments to a method that will do a shallow copy of all properties.

Detail

This means that the following will work:

var foo = { a: 1 };
var bar = { b: 2 };
bar.__proto__ = foo;
bar.a; // 1
bar.b; // 2

however the following will not:

var foo = { a: 1 };
var bar = { b: 2 };
bar.__proto__ = foo;
bar.a; // 1
foo.a = 2;
bar.a; // 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 = ...;

_defaults(bar, foo);

Installation

npm install --save-dev babel-plugin-transform-proto-to-assign

Usage

.babelrc

{
  "plugins": ["transform-proto-to-assign"]
}

Via CLI

babel --plugins transform-proto-to-assign script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-proto-to-assign"]
});