babel-plugin-transform-object-rest-spread
Compile object rest and spread to ES5
Last updated 8 years ago by hzoo .
MIT · Repository · Original npm · Tarball · package.json
$ gnpm install babel-plugin-transform-object-rest-spread 
SYNC missed versions from official npm registry.

babel-plugin-transform-object-rest-spread

This plugin allows Babel to transform rest properties for object destructuring assignment and spread properties for object literals.

Example

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

let n = { x, y, ...z };
console.log(n); // { x: 1, y: 2, a: 3, b: 4 }

Installation

npm install --save-dev babel-plugin-transform-object-rest-spread

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-object-rest-spread"]
}

Via CLI

babel --plugins transform-object-rest-spread script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-object-rest-spread"]
});

Options

useBuiltIns

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

{
  "plugins": [
    ["transform-object-rest-spread", { "useBuiltIns": true }]
  ]
}

In

z = { x, ...y };

Out

z = Object.assign({ x }, y);

References

Current Tags

  • 6.26.0                                ...           latest (7 years ago)
  • 7.0.0-beta.3                                ...           next (7 years ago)

39 Versions

  • 7.0.0-beta.3                                ...           7 years ago
  • 7.0.0-beta.2                                ...           7 years ago
  • 7.0.0-beta.1                                ...           7 years ago
  • 7.0.0-beta.0                                ...           7 years ago
  • 7.0.0-alpha.20                                ...           7 years ago
  • 6.26.0                                ...           7 years ago
  • 7.0.0-alpha.19                                ...           7 years ago
  • 7.0.0-alpha.18                                ...           7 years ago
  • 7.0.0-alpha.17                                ...           7 years ago
  • 7.0.0-alpha.16                                ...           7 years ago
  • 7.0.0-alpha.15                                ...           7 years ago
  • 7.0.0-alpha.14                                ...           7 years ago
  • 7.0.0-alpha.12                                ...           8 years ago
  • 7.0.0-alpha.11                                ...           8 years ago
  • 7.0.0-alpha.10                                ...           8 years ago
  • 7.0.0-alpha.9                                ...           8 years ago
  • 7.0.0-alpha.8                                ...           8 years ago
  • 7.0.0-alpha.7                                ...           8 years ago
  • 7.0.0-alpha.3                                ...           8 years ago
  • 7.0.0-alpha.1                                ...           8 years ago
  • 6.23.0                                ...           8 years ago
  • 6.22.0                                ...           8 years ago
  • 6.20.2                                ...           8 years ago
  • 6.20.1                                ...           8 years ago
  • 6.20.0                                ...           8 years ago
  • 6.19.0                                ...           8 years ago
  • 6.16.0                                ...           8 years ago
  • 6.8.0                                ...           9 years ago
  • 6.6.5                                ...           9 years ago
  • 6.6.4                                ...           9 years ago
  • 6.5.0-1                                ...           9 years ago
  • 6.5.0                                ...           9 years ago
  • 6.3.13                                ...           9 years ago
  • 6.2.4                                ...           9 years ago
  • 6.1.18                                ...           9 years ago
  • 6.1.17                                ...           9 years ago
  • 6.1.4                                ...           9 years ago
  • 6.0.14                                ...           9 years ago
  • 6.0.2                                ...           9 years ago
Downloads
Today 0
This Week 0
This Month 18
Last Day 0
Last Week 18
Last Month 0
Dependencies (2)
Dev Dependencies (1)

Copyright 2013 - present © cnpmjs.org | Home |