babel/packages/babel-plugin-transform-destructuring
Anatoli Papirovski aefbb1380e No unneeded empty arrays in transform spread (#6763)
* No unneeded empty arrays in transform spread

Since Array.prototype.concat creates a new array from inputs, there's
no need to call it from a new empty array ([].concat()).

* [fixup] simplify detection of new array
2017-11-09 14:51:56 -05:00
..
2017-11-03 16:03:01 -04:00

@babel/plugin-transform-destructuring

Compile ES2015 destructuring to ES5

Examples

In

let arr = [1,2,3];
let {x, y, z} = arr;

Out

var arr = [1, 2, 3];
var x = arr.x,
    y = arr.y,
    z = arr.z;

Installation

npm install --save-dev @babel/plugin-transform-destructuring

Usage

.babelrc

{
  "plugins": ["@babel/transform-destructuring"]
}

Via CLI

babel --plugins @babel/transform-destructuring script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/transform-destructuring"]
});