Socket
Socket
Sign inDemoInstall

@babel/plugin-proposal-object-rest-spread

Package Overview
Dependencies
82
Maintainers
5
Versions
86
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0-beta.49 to 7.0.0-beta.50

10

package.json
{
"name": "@babel/plugin-proposal-object-rest-spread",
"version": "7.0.0-beta.49",
"version": "7.0.0-beta.50",
"description": "Compile object rest and spread to ES5",

@@ -12,4 +12,4 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-object-rest-spread",

"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.49",
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.49"
"@babel/helper-plugin-utils": "7.0.0-beta.50",
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.50"
},

@@ -20,5 +20,5 @@ "peerDependencies": {

"devDependencies": {
"@babel/core": "7.0.0-beta.49",
"@babel/helper-plugin-test-runner": "7.0.0-beta.49"
"@babel/core": "7.0.0-beta.50",
"@babel/helper-plugin-test-runner": "7.0.0-beta.50"
}
}
# @babel/plugin-proposal-object-rest-spread
> This plugin allows Babel to transform rest properties for object destructuring assignment and spread properties for object literals.
> Compile object rest and spread to ES5
## Example
See our website [@babel/plugin-proposal-object-rest-spread](https://new.babeljs.io/docs/en/next/babel-plugin-proposal-object-rest-spread.html) for more information.
### Rest Properties
## Install
```js
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 }
```
Using npm:
### Spread Properties
```js
let n = { x, y, ...z };
console.log(n); // { x: 1, y: 2, a: 3, b: 4 }
```
## Installation
```sh
npm install --save-dev @babel/plugin-proposal-object-rest-spread
npm install --save @babel/plugin-proposal-object-rest-spread
```
## Usage
or using yarn:
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": ["@babel/plugin-proposal-object-rest-spread"]
}
```
### Via CLI
```sh
babel --plugins @babel/plugin-proposal-object-rest-spread script.js
yarn add --save @babel/plugin-proposal-object-rest-spread
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-proposal-object-rest-spread"]
});
```
## Options
By default, this plugin will produce spec compliant code by using Babel's `objectSpread` helper.
### `loose`
`boolean`, defaults to `false`.
Enabling this option will use Babel's `extends` helper, which is basically the same as `Object.assign` (see `useBuiltIns` below to use it directly).
:warning: Please keep in mind that even if they're almost equivalent, there's an important difference between spread and `Object.assign`: **spread _defines_ new properties, while `Object.assign()` _sets_ them**, so using this mode might produce unexpected results in some cases.
For detailed information please check out [Spread VS. Object.assign](http://2ality.com/2016/10/rest-spread-properties.html#spreading-objects-versus-objectassign) and [Assigning VS. defining properties](http://exploringjs.com/es6/ch_oop-besides-classes.html#sec_assigning-vs-defining-properties).
### `useBuiltIns`
`boolean`, defaults to `false`.
Enabling this option will use `Object.assign` directly instead of the Babel's `extends` helper.
##### Example
**.babelrc**
```json
{
"plugins": [
["@babel/plugin-proposal-object-rest-spread", { "loose": true, "useBuiltIns": true }]
]
}
```
**In**
```js
z = { x, ...y };
```
**Out**
```js
z = Object.assign({ x }, y);
```
## References
* [Proposal: Object Rest/Spread Properties for ECMAScript](https://github.com/sebmarkbage/ecmascript-rest-spread)
* [Spec](http://sebmarkbage.github.io/ecmascript-rest-spread)
* [Spread VS. Object.assign](http://2ality.com/2016/10/rest-spread-properties.html#spreading-objects-versus-objectassign)
* [Assigning VS. defining properties](http://exploringjs.com/es6/ch_oop-besides-classes.html#sec_assigning-vs-defining-properties)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc