W3cubDocs

/Babel

ES5 property mutators transform

Transform object initializer mutators into Object.defineProperties

Example

In

var foo = {
  get bar() {
    return "bar";
  }
};

Out

var foo = Object.defineProperties({}, {
  bar: {
    get: function () {
      return "bar";
    },
    enumerable: true,
    configurable: true
  }
});

Installation

npm install --save-dev babel-plugin-transform-es5-property-mutators

Usage

.babelrc

{
  "plugins": ["transform-es5-property-mutators"]
}

Via CLI

babel --plugins transform-es5-property-mutators script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-es5-property-mutators"]
});

© 2018 Sebastian McKenzie
Licensed under the MIT License.
http://babeljs.io/docs/plugins/transform-es5-property-mutators/