ast-declaration-source
Given an esprima/acorn-style AST, approximately find the original declaration node responsible for a variable.
Usage
declaration = source(node)
Given a node
within an AST generated by esprima
or acorn, determine the original declaration
node
in the tree.
Returns undefined
if a suitable node could not be found.
Note that you'll need to use astw or a similar package
to add the "parent" properties to each node required for
ast-declaration-source
to successfully navigate the tree.
var source =var escodegen =var acorn =var astw =var fs =var src = fsvar ast = acorn// required to assign "parent" properties// to each node{}var srcNode = astbody6declarations0initarguments0var declNode =consoleconsoleconsoleconsoleconsoleconsole
License
MIT. See LICENSE.md for details.