es6-destructuring

2019-09-08 admin

es6-destructuring是什么

什么是es6-destructuring,es6 destructuring compiled to es3

es6-destructuring使用教程帮助文档

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 via npm 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;

Acknowledgements

This module is a port of Andrey Popp es6-destructuring-jstransform project, I wanted a recast based transformer, and that’s why I ported it, part of square es6-arrow-function code has also been used for this module, thanks to Andrey Popp and Square for their amazing work, and thanks to Ben Newman for the amazing recast project.

你可能感兴趣的文章:

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-74645.html

文章标题:es6-destructuring

回到顶部