🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

estree-visitor

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

estree-visitor

Lightweight ESTree traversal

latest
Source
npmnpm
Version
1.0.8
Version published
Maintainers
1
Created
Source

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

Keywords

ESTree

FAQs

Package last updated on 18 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts