$ npm install ast-plugin
The simplest abstract syntax tree walker.
npm i --save ast-plugin
import { Ast, Plugin } from 'ast-plugin';
new Ast(ast).traverse([
new TestPlugin(cfg),
// ...
]);
import { Ast, Plugin } from 'ast-plugin';
class TestPlugin extends Plugin {
pre = () => {};
visitor = () => {
return {
// process node with type = 'text'
text: ast => {
console.log(ast.node);
ast.segment();
},
};
};
post = () => {};
}
MIT@hustcc.
© 2010 - cnpmjs.org x YWFE | Home | YWFE