estree-visitor

1.0.8 • Public • Published

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

Package Sidebar

Install

npm i estree-visitor

Weekly Downloads

0

Version

1.0.8

License

mit

Unpacked Size

293 kB

Total Files

14

Last publish

Collaborators

  • iggredible