Walks a JavaScript AST, such as one supplied via
esprima, and adds a parent
property to each node.
Makes it much easier to navigate the AST, and the parent
properties
added here are non-enumerable so you can still serialize the tree to JSON
without JSON.stringify
throwing an error.
Usage
require('ast-parents')(ast)
Where ast
is an AST object. For example:
var esprima =var fs =var src = fsvar ast = esprimaastbody0parent === astbody
License
MIT. See LICENSE.md for details.