You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
4 years ago | |
|---|---|---|
| .. | ||
| .github/workflows | 4 years ago | |
| bench | 4 years ago | |
| test | 4 years ago | |
| .travis.yml | 4 years ago | |
| CHANGELOG.md | 4 years ago | |
| LICENSE.md | 4 years ago | |
| README.md | 4 years ago | |
| index.js | 4 years ago | |
| package.json | 4 years ago | |
README.md
dash-ast
walk an AST, quickly
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.