Sha256: daecb99fce25024fada481078ae15b016e767ea84376089c5590082064cbf55c
Contents?: true
Size: 475 Bytes
Versions: 11
Compression:
Stored size: 475 Bytes
Contents
var esprima = require("esprima").parse; var traverse = require("ast-traverse"); var ast = esprima("f(!x, y)"); var val; try { traverse(ast, {pre: function(node) { if (node.type === "UnaryExpression" && node.operator === "!") { val = node.argument; throw 0; } }}); } catch(e) { if (val === undefined) { throw e; // re-throw if it wasn't our exception } } console.dir(val); // { type: 'Identifier', name: 'x' }
Version data entries
11 entries across 11 versions & 4 rubygems