Skip to content

Instantly share code, notes, and snippets.

@icefapper
Last active November 30, 2017 16:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
var src = 'var a, b, l = {a, [b]: {l}} = ({A}=a) => a = ({B=b}) => b = ({L=l}=40) => l';
// parse it
var syntaxNode = new Parser(src).parseProgram();
// transform what was parsed
var transformer = new Transformer();
transformer.renamer = renamer_minify;
var transformedNode = transformer.tr(syntaxNode, false);
// emit what was transformed
var emitter = new Emitter();
emitter.allow.space = false;
emitter.allow.nl = false;
emitter.allow.comments.l = false;
emitter.allow.comments.m = false;
emitter.startFreshLine()
emitter.emitStmt(transformedNode);
emitter.flushCurrentLine(); // flush whatever output that is still pending
// the compiled code:
console.log(emitter.out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment