estree-visitor
Lightweight ESTree traversal
Last updated 5 months ago by iggredible .
mit · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install estree-visitor 
SYNC missed versions from official npm registry.

ESTree-visitor

Traverse through Javascript AST as described by ESTree-spec.

Installation / Usage

Run npm i estree-visitor

Visitor accepts an optional enter function so you can play around with current ESTree node you are on!

const visitor = require("estree-visitor");
const acorn = require("acorn");

const statement = "console.log('hello')"; // pass any JS code
const ast = acorn.parse(statement);
visitor(ast, {
  enter: function(currentNode) {
    console.log("current node: ", currentNode);
    // do more stuff with currentNode
  }
});

Example

Check out the demo folder for an example.

cd demo
npm i
npm run start-demo // will run on localhost:1234

License

MIT

Current Tags

  • 1.0.8                                ...           latest (5 months ago)

4 Versions

  • 1.0.8                                ...           5 months ago
  • 1.0.6                                ...           5 months ago
  • 1.0.4                                ...           5 months ago
  • 1.0.0                                ...           5 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |