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

Version Path
ilog-0.4.1 node_modules/breakable/examples/example-explicit.js
ilog-0.4.0 node_modules/breakable/examples/example-explicit.js
ilog-0.3.3 node_modules/breakable/examples/example-explicit.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/breakable/examples/example-explicit.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/breakable/examples/example-explicit.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/breakable/examples/example-explicit.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/breakable/examples/example-explicit.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/breakable/examples/example-explicit.js
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/breakable/examples/example-explicit.js
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/breakable/examples/example-explicit.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/breakable/examples/example-explicit.js