Subscribed unsubscribe Subscribe Subscribe

枕を欹てて聴く

香炉峰の雪は簾を撥げて看る

ECMAScript code generator: escodegen

Keeping Esprima core simple

Esprimaのcoreをparser levelに保つということで, code generatorが単一のmoduleになりました.

escodegen

Install

npm install escodegen

example

simple example: (from http://ariya.ofilabs.com/2012/02/primavera-updates-of-esprima.html )

escodegen.generate({
    type: 'BinaryExpression',
    operator: '+',
    left: { type: 'Literal', value: 40 },
    right: { type: 'Literal', value: 2 }
});

and gets following string

40 + 2

See API page for more information.

Future plans

  • adding minify option
  • adding SourceMap option