dash-ast
walk an AST, quickly
Last updated 8 months ago by goto-bus-stop .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dash-ast 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.0.1                                ...           latest (8 months ago)

3 Versions

  • 2.0.1                                ...           8 months ago
  • 2.0.0                                ...           8 months ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 205
This Week 1,835
This Month 11,081
Last Day 826
Last Week 3,497
Last Month 17,050
Dependencies (0)
None
Dev Dependencies (8)

Copyright 2014 - 2016 © taobao.org |