$ cnpm install @putout/traverse
traverse AST-nodes
npm i @putout/traverse
import {template} from '@putout/engine-parser';
import {traverse} from '@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');
},
});
import {template} from '@putout/engine-parser';
import {contains} from '@putout/traverse';
const node = template.ast('async () => await x');
contains(node, [
'return __',
'throw __',
'await __',
'for await (__ of __) __',
]);
// returns
true;
MIT
Copyright 2013 - present © cnpmjs.org | Home |