Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

estree-modules

0.1.0 • Public • Published

estree-modules

Get module imports and exports from a node.

var esprima = require('esprima')
var modules = require('estree-modules')
 
var node = esprima.parse(/* ... */)
 
var importNodes = modules.imports(node)
var exportNodes = modules.exports(node)

Installation

$ npm install --save estree-modules

Usage

modules.imports(node)

Get an array of require and import nodes.

modules.imports(node);
// [ ImportDeclaration { ... },
//   ImportDeclaration { ... },
//   CallExpression { ... } ]

(Using estree-ancestors on the CallExpression nodes can give more useful info)

modules.exports(node)

Get an array of module.exports/exports assignment nodes or export declaration nodes.

modules.exports(node)
// [ ExportNamedDeclaration { ... },
//  AssignmentExpression { ... },
//  AssignmentExpression { ... } ]

License

MIT © Jamen Marz


version travis downloads license follow

install

npm i estree-modules

Downloadsweekly downloads

7

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar