es6-destructuring
desugar ES6 destructuring to ES5.var {x, y} = z;
function x(x, {y}) {
}
compiles to this:
var x = z.x, y = z.y;
function x(arg$0) {
var y = arg$0.y;
}
Install
$ npm install es6-destructuring
Usage
$ node
> var compile = require('es6-destructuring').compile;
[Function]
> compile('var {x, y} = z;').code;
'var x = z.x, y = z.y;'
Command line
If installing vianpm
a command line tool will be available called es6-destructuring
.$ echo "var {x, y} = z;" | es6-destructuring
var x = z.x, y = z.y;
$ es6-destructuring $file
var x = z.x, y = z.y;
Browserify
Browserify support is built in.$ npm install es6-destructuring # install local dependency
$ browserify -t es6-destructuring $file
// BOILERPLATE
var x = z.x, y = z.y;