Skip to content

Commit

Permalink
Fix transform-object-rest-spread README [skip ci] (#5409)
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism authored and hzoo committed Mar 3, 2017
1 parent 0d3a7e9 commit 2127df0
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions packages/babel-plugin-transform-object-rest-spread/README.md
Expand Up @@ -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
Expand All @@ -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
{
Expand All @@ -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
Expand Down

0 comments on commit 2127df0

Please sign in to comment.