JSPM

morpher

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q37918F
  • License MIT

JavaScript AST transformer and code generator

Package Exports

  • morpher

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (morpher) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Morpher

Build Status

JavaScript AST transformer and code generator, optimized for older engines.

Inspired by Falafel (https://github.com/substack/node-falafel), but modified for performance in older JavaScript engines (eg. IE8.)

Example

var code = 'var result = 1 + 2;';
var ast = acorn.parse(code, {ranges: true});
var transpiledCode = morpher.morph(code, ast, function (node, parent, replace, source) {
    if (node.type === 'BinaryExpression') {
        replace(node, 'postProcess(' + source(node) + ')');
    }
});
console.log(transpiledCode); // Outputs `var result = postProcess(1 + 2);`

Keeping up to date