defnode

0.0.5 • Public • Published

defnode

xrefs funcs top func library users status

defnode is a node.js package that maps JavaScript Identifier AST nodes to/from their corresponding definition nodes. It is useful in tools that perform JavaScript source introspection.

For example, suppose we have the following code.

function a(b) {
  var c = 1, d;
}

defnode maps the following Identifier/definition pairs:

  • a to/from the enclosing FunctionDeclaration node
  • b to/from itself (since its Identifier node is its own declaration)
  • c to/from its VariableDeclarator node
  • d to/from its VariableDeclarator node

defnode uses marijnh/tern, but it should work with any SpiderMonkey API-compliant JavaScript AST.

Documentation: defnode.js on Sourcegraph

Running tests

Run npm test.

Contributors

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.5
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.5
    2
  • 0.0.4
    1
  • 0.0.3
    1
  • 0.0.2
    2
  • 0.0.1
    1

Package Sidebar

Install

npm i defnode

Weekly Downloads

7

Version

0.0.5

License

none

Last publish

Collaborators

  • sqs