reflect-unbuilder

0.0.2 • Public • Published

The Unbuilder

An AST-to-source-code serializer for reflect.js.

Example:

var Reflect = require('reflect');
var unbuilder = require('reflect-unbuilder');

var source = "a + b + c(5)";
var ast = Reflect.parse(source, {builder: unbuilder});

console.log(ast.unbuild("builder", '', false));

/* Output:
builder.program(
  [ builder.expressionStatement(builder.binaryExpression(
      "+",
      builder.binaryExpression(
        "+",
        builder.identifier("a"),
        builder.identifier("b")
      ),
      builder.callExpression(
        builder.identifier("c"),
        [ builder.literal(5) ]
      )
    )) ]
)
*/

The output tries to be somewhat readable. Reformat at will.

Install

npm install reflect-unbuilder

Node Properties

See the Mozilla documentation for the default node APIs. The following are additional properties provided by unbuilder.

node.unbuild(builderName, indent, includeLocationFlag)

  • The serialized builder constructors will use builderName as the builder object.
  • indent is the initial indentation level.
  • includeLocationFlag determines if location data is included in the serialization.

License

MIT X License

Readme

Keywords

none

Package Sidebar

Install

npm i reflect-unbuilder

Weekly Downloads

3

Version

0.0.2

License

none

Last publish

Collaborators

  • zaach