ast-plugin
The simplest abstract syntax tree walker.
Last updated 8 years ago by atool .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install ast-plugin 
SYNC missed versions from official npm registry.

ast-plugin

The simplest abstract syntax tree walker.

Install

npm i --save ast-plugin

Usage

  • Traverse Ast plugins
import { Ast, Plugin } from 'ast-plugin';

new Ast(ast).traverse([
  new TestPlugin(cfg),
  // ...
]);
  • Write an ast plugin
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 = () => {};
}

Used by

  • lint-md: Cli tool to lint your markdown file for Chinese.

License

MIT@hustcc.

Current Tags

  • 0.0.7                                ...           latest (8 years ago)

8 Versions

  • 0.0.7                                ...           8 years ago
  • 0.0.6                                ...           8 years ago
  • 0.0.5                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
  • 0.0.1-beta.1                                ...           8 years ago
Maintainers (1)
Downloads
Total 25
Today 0
This Week 7
This Month 16
Last Day 5
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (13)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE