Execute a callback on every node of a source code's AST and stop walking when you see fit
Execute a callback on every node of a file's AST and stop walking whenever you see fit.
npm install node-source-walk
var Walker = require'node-source-walk';var walker = ;// Assume src is the string contents of myfile.js// or the AST of an outside parse of myfile.jswalkerwalksrcif /* some condition */// No need to keep traversing since we found what we wantedwalkerstopWalking;;
By default, Walker will use
acorn supporting ES5, but you can switch to es6 as follows:
var walker =ecmaVersion: 6;