An AST-to-source-code serializer for reflect.js
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
test
.gitignore
README.md
package.json

README.md

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