npm-flat-graph

0.0.1 • Public • Published

npm-flat-graph Flattr this!experimental

Given a list of modules, recursively retrieve their dependency graph and generate a flat list of each module's dependencies.

Useful if you're only concerned with the most recent versions of a dependency tree, generally for visualisation/analysis.

Usage

npm-flat-graph

getGraph(modules, [opts], done)

This function takes an array of modules by name, calling done(err, results) when complete, supplying you with an index formatted like so:

{
  'envify': [ 'xtend', 'through', 'esprima-fb', 'jstransform' ],
  'esprima-fb': [],
  'jstransform': [ 'base62', 'esprima-fb', 'source-map' ],
  'through': [],
  'xtend': [ 'object-keys' ],
  'base62': [],
  'object-keys': [],
  'source-map': [ 'amdefine' ],
  'amdefine': []
}

You can also pass the following options:

  • opts.exclude: an array of module names to not include in the final output. Its dependencies won't be resolved either, so is useful for elimating unwanted development dependencies and the like.

License

MIT. See LICENSE.md for details.

Package Sidebar

Install

npm i npm-flat-graph

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • hughsk