$ npm install @putout/traverse
traverse AST-nodes
npm i @putout/traverse
const {template} = require('@putout/engine-parser');
const {traverse} = require('@putout/traverse');
const node = template.ast('const a = b');
traverse(node, {
'Identifier'(path) {
console.log('found identifier');
},
'throw __a'(path, {__a}) {
console.log(__a);
},
'await __'(path) {
console.log('found await');
},
'for await (__ of __) __'(path) {
console.log('found for-of');
},
});
const {template} = require('@putout/engine-parser');
const {contains} = require('@putout/traverse');
const node = template.ast('async () => await x');
contains(node, [
'return __',
'throw __',
'await __',
'for await (__ of __) __',
]);
// returns
true;
MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE