Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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

install

npm i constructuring

Downloadsweekly downloads

0

version

0.0.3

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar