Skip to content

Instantly share code, notes, and snippets.

@icefapper
Last active Nov 30, 2017
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