Object set prototype of to assign transform

This plugin will transform all `Object.setPrototypeOf` calls to a method that will do a shallow defaults of all properties.

NOTE: There are some caveats when using this plugin, see the babel-plugin-transform-proto-to-assign README for more information..

注意: 使用此插件时有一些注意事项,请参阅 babel-plugin-transform-proto-to-assign README 了解更多信息。

示例

输入

Object.setPrototypeOf(bar, foo);

输出

var _defaults = ...;

_defaults(bar, foo);

安装

npm install --save-dev babel-plugin-transform-object-set-prototype-of-to-assign

用法

通过 .babelrc(推荐)

.babelrc

{
  "plugins": ["transform-object-set-prototype-of-to-assign"]
}

通过 CLI

babel --plugins transform-object-set-prototype-of-to-assign script.js

通过 Node API

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