Package detail

dash-ast

goto-bus-stop6.1mApache-2.02.0.1

walk an AST, quickly

ast, estree, javascript, parse

readme

dash-ast

walk an AST, quickly

npm travis standard

Install

npm install dash-ast

Usage

var dashAst = require('dash-ast')
var isIdentifier = require('estree-is-identifier')

var deps = []
dashAst(ast, function (node, parent) {
  if (node.type === 'CallExpression' && isIdentifier(node.callee, 'require')) {
    deps.push(node.arguments[0])
  }
})

API

dashAst(ast, callback)

Call callback(node, parent) on each node in ast. This does a preorder traversal, i.e. callback receives child nodes after the parent node.

dashAst(ast, { enter, leave })

Call enter(node, parent) on each node in ast before traversing its children, and call leave(enter, parent) on each node after traversing its children. If a node does not have children, enter() and leave() are called immediately after each other.

License

Apache-2.0

changelog

dash-ast change log

All notable changes to this project will be documented in this file.

This project adheres to Semantic Versioning.

2.0.1

  • Remove obsolete .withParent() documentation from the readme.

2.0.0

  • Remove .withParent().
  • Reduce repeated dictionary access, up to ~10% faster.

1.0.0

  • Initial release.