constructuring

0.0.3 • Public • Published

Constructuring

About

Constructuring is a ndoe module that transforms Javascript code that uses ES6's destructuring feature into code that runs on today's browsers.

Example

Transforming a javascript file.

var transformSource = require('constructuring').transformSource;
var source = fs.readFileSync('module_with_destructuring_code.js');
console.log(transformSource(source));

Transforming an esprima AST. This option is prefered when you are doing more than one transformation on your code.

var transform = require('constructuring').transform;
var esprima = require('esprima');
var escodegen = require('escodegen');
 
var source = fs.readFileSync('module_with_destructuring_code.js');
var ast = esprima.parse(source);
transform(ast);
// do more transformations on the same ast
console.log(escodegen.generate(ast));

Contributing

Running tests

Make sure you install mocha then run:

mocha --harmony

Dependents (0)

Package Sidebar

Install

npm i constructuring

Weekly Downloads

1

Version

0.0.3

License

MIT

Last publish

Collaborators

  • fabiomcosta