babel-plugin-transform-object-rest-spread
Compile object rest and spread to ES5
Last updated 2 years ago by hzoo .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm 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 (2 years ago)
  • 7.0.0-beta.3                                ...           next (2 years ago)

39 Versions

  • 7.0.0-beta.3                                ...           2 years ago
  • 7.0.0-beta.2                                ...           2 years ago
  • 7.0.0-beta.1                                ...           2 years ago
  • 7.0.0-beta.0                                ...           2 years ago
  • 7.0.0-alpha.20                                ...           2 years ago
  • 6.26.0                                ...           2 years ago
  • 7.0.0-alpha.19                                ...           2 years ago
  • 7.0.0-alpha.18                                ...           2 years ago
  • 7.0.0-alpha.17                                ...           2 years ago
  • 7.0.0-alpha.16                                ...           2 years ago
  • 7.0.0-alpha.15                                ...           2 years ago
  • 7.0.0-alpha.14                                ...           2 years ago
  • 7.0.0-alpha.12                                ...           2 years ago
  • 7.0.0-alpha.11                                ...           2 years ago
  • 7.0.0-alpha.10                                ...           2 years ago
  • 7.0.0-alpha.9                                ...           2 years ago
  • 7.0.0-alpha.8                                ...           2 years ago
  • 7.0.0-alpha.7                                ...           2 years ago
  • 7.0.0-alpha.3                                ...           2 years ago
  • 7.0.0-alpha.1                                ...           2 years ago
  • 6.23.0                                ...           3 years ago
  • 6.22.0                                ...           3 years ago
  • 6.20.2                                ...           3 years ago
  • 6.20.1                                ...           3 years ago
  • 6.20.0                                ...           3 years ago
  • 6.19.0                                ...           3 years ago
  • 6.16.0                                ...           3 years ago
  • 6.8.0                                ...           3 years ago
  • 6.6.5                                ...           3 years ago
  • 6.6.4                                ...           3 years ago
  • 6.5.0-1                                ...           4 years ago
  • 6.5.0                                ...           4 years ago
  • 6.3.13                                ...           4 years ago
  • 6.2.4                                ...           4 years ago
  • 6.1.18                                ...           4 years ago
  • 6.1.17                                ...           4 years ago
  • 6.1.4                                ...           4 years ago
  • 6.0.14                                ...           4 years ago
  • 6.0.2                                ...           4 years ago
Downloads
Today 398
This Week 21,124
This Month 160,459
Last Day 10,393
Last Week 57,307
Last Month 247,721
Dependencies (2)
Dev Dependencies (1)
Dependents (2644)

Copyright 2014 - 2016 © taobao.org |