babel/doc/usage/api.md
2015-01-05 23:27:46 -08:00

852 B

layout title description permalink
docs API How to use the Node.js API. /docs/usage/api/
var to5 = require('6to5');

to5.transform

Transforms the passed in code.

to5.transform(code, [options])

Example

var result = to5.transform('code();', options);
result.code;
result.map;
result.ast;

to5.transformFile

Asynchronously transforms the entire contents of a file.

to5.transformFile(filename, [options], callback)

Example

to5.transformFile('filename.js', options, function (err, result) {
  result.code;
});

to5.transformFileSync

Synchronous version of to5.transformFile. Returns the transformed contents of the filename.

to5.transformFileSync(filename, [options])

Example

to5.transformFileSync('filename.js', options).code;