New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

cortex-deps-traveller

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cortex-deps-traveller

Travel dependency tree for cortex

3.0.1
latest
Version published
Weekly downloads
52
1633.33%
Maintainers
5
Weekly downloads
 
Created

Cortex Deps Traveller - Travel Package Dep Tree

NPM version Build Status Dependency Status

Traveling cortex packages through dependencies tree.

Install

$ npm install cortex-deps-traveller --save

Usage

var traveller = require('cortex-deps-traveller')(built_root, {
  maxDepth: 3
});

traveller.toJSONTree(pkg, function(err, tree) {
  
});


// Advanced Usage, visit will travel the dep tree with BFS (which is better for performance)
traveller.visit(pkg, {
  enter: function(node, parent) {
      node.pkg; // pkg info
      node.from; // resolved from

      if(parent == null) {
        // is root node, with non-parent
      }
  }, leave: function(node, parent) {

  }
}, function(err) {
  // all things is done
  
});


var Traveller = require('cortex-deps-traveller').Traveller;

APIs

new Traveller(built_root, [options])

Options
  • max_depth number
  • dev boolean
  • async boolean
  • pkgDeps function

traveller.toJSONTree(pkg, callback)

Generate dependencies tree from pkg

traveller.visit(pkg, visitor, done)

Visit the dependencies tree of pkg with a visitor

  • pkg {Object} pkg info object
  • visitor {Visitor} visitor
  • done {function} called when all the nodes are visited

traveller.topsort(tree, [rootName])

Return a sorted array from the tree

traveller.toJSONTree(pkg, function(err, json) {
    var sorted = traveller.topsort(json, pkg.name);
});
  • tree {Object} dependencies tree
  • rootName {string=} the name of root package in the tree, used for output and cycle-detection

traveller.resolvePackage(name, range|version, callback)

Read package information object from name and range, which utilized the internal cache in traveller

traveller.resolvePackage(name, range, function(err, pkg) {
   // pkg is read from cortex.json
});

traveller.resolveRange(name, range, callback)

Return a version resolved from range for package

traveller.resolveRange(name, range, function(err, version) {
   // 
});

traveller.readVersions(name, callback)

Return an array of available versions.

traveller.readVersions(name, function(err, versions) {
  // do something on versions
});
  • name {string} package name
  • callback {function}

module.exports.topsort(root, [name])

Licence

MIT

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts