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 ES6 (and JSX) and the
sourceType: module, but you can change any of the defaults as follows:
var walker =ecmaVersion: 5sourceType: 'script';