babel/packages/babel-plugin-transform-es2015-destructuring
Benedikt Meurer 5baa36109e Fix access to "-1" property on nodesOut array. (#6582)
Similar to the fixes in https://github.com/babel/babel/pull/6580 and
https://github.com/babel/babel/pull/6581, accesses of the form

```js
nodesOut[nodesOut.length - 1]
```

where `nodesOut` can be an empty array, are bad for performance in Node.
In this particular case it's easy to restructure the code a bit to not
require the array access at all, but just track the current `tail` as we
go.

This is a non-breaking performance fix.
2017-10-28 20:16:04 -04:00
..
2017-03-25 21:46:16 -04:00

@babel/plugin-transform-es2015-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-es2015-destructuring

Usage

.babelrc

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

Via CLI

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

Via Node API

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