This is super useful if you want to roll your own stack traces or build a code coverage tool.
var burrito = ;var res = burrito;console; // sin(pi / 2) == 1
var burrito = ;var src =;console;
qqq(f()) && qqq(g(qqq(h()))); qqq(foo());
var burrito = require('burrito');
Given some source
code and a function
trace, walk the ast by expression.
cb gets called with a node object described below.
code is an Array then it is assumbed to be an AST which you can generate
burrito.parse(). The AST must be annotated, so make sure to
burrito.parse(src, false, true).
burrito() except the result is run using
Name is a string that contains the type of the expression as named by uglify.
Wrap the current expression in
s is a string,
"%s" will be replaced with the stringified current
s is a function, it is called with the stringified current expression and
should return a new stringified expression.
node.name === "binary", you get the subterms "%a" and "%b" to play with
too. These subterms are applied if
s is a function too:
s(expr, a, b).
if nodename === 'stat' node
raw ast data generated by uglify
node.node.slice(1) to skip the annotations
The start location of the expression, like this:
type: 'name'value: 'b'line: 0col: 3pos: 3nlb: falsecomments_before:
The end location of the expression, formatted the same as
The state of the traversal using traverse.
Returns a stringified version of the expression.
Returns the parent
null if the node is the root element.
Return the label of the present node or
null if there is no label.
Labels are returned for "call", "var", "defun", and "function" nodes.
Returns an array for "var" nodes since
var statements can
contain multiple labels in assignment.
With npm you can just:
npm install burrito
Burrito works in browser with browserify.
It has been tested against:
Heavily inspired by (and previously mostly lifted outright from) isaacs's nifty tmp/instrument.js thingy from uglify-js.