diff --git a/packages/babel-plugin-transform-object-rest-spread/README.md b/packages/babel-plugin-transform-object-rest-spread/README.md index 61c3debfff7a..79f2432d03f8 100644 --- a/packages/babel-plugin-transform-object-rest-spread/README.md +++ b/packages/babel-plugin-transform-object-rest-spread/README.md @@ -4,19 +4,22 @@ ## Example +### Rest Properties + ```js -// Rest properties let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; console.log(x); // 1 console.log(y); // 2 console.log(z); // { a: 3, b: 4 } +``` + +### Spread Properties -// Spread properties +```js let n = { x, y, ...z }; console.log(n); // { x: 1, y: 2, a: 3, b: 4 } ``` - ## Installation ```sh @@ -35,11 +38,29 @@ npm install --save-dev babel-plugin-transform-object-rest-spread } ``` +### Via CLI + +```sh +babel --plugins transform-object-rest-spread script.js +``` + +### Via Node API + +```javascript +require("babel-core").transform("code", { + plugins: ["transform-object-rest-spread"] +}); +``` + ## Options -This plugin will use babel's `extends` helper, which will polyfill `Object.assign` by default. +### `useBuiltIns` -* `useBuiltIns` - Do not use Babel's helper's and just transform to use the built-in method (Disabled by default). +`boolean`, defaults to `false`. + +By default, this plugin uses Babel's `extends` helper which polyfills `Object.assign`. Enabling this option will use `Object.assign` directly. + +**.babelrc** ```json { @@ -49,25 +70,16 @@ This plugin will use babel's `extends` helper, which will polyfill `Object.assig } ``` +**In** + ```js -// source z = { x, ...y }; -// compiled -z = Object.assign({ x }, y); -``` - -### Via CLI - -```sh -babel --plugins transform-object-rest-spread script.js ``` -### Via Node API +**Out** -```javascript -require("babel-core").transform("code", { - plugins: ["transform-object-rest-spread"] -}); +```js +z = Object.assign({ x }, y); ``` ## References