npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

deptrace

v0.2.4

Published

Trace and format recursive dependency trees asynchronously.

Readme

deptrace Build Status

Trace and format recursive dependency trees asynchronously.

NPM

API

constructor(opts)

Create an instance of Deptrace to trace your dependencies.

const tracer = new Deptrace({
  setup: function () {
    // optional method to call before running graph
  },
  depsFor: function (input) {
    // extract an array of dependencies from some input
  },
  resolve: function (dep, parents) {
    // resolve an individual dependency into a more detailed form
  },
  format: function (input, children, tree) {
    // format a node in a dependency graph after all dependencies are resolved
  },
  concurrency: 4
});

opts.setup

Use this to perform any setup necessary before running a graph. May return a promise.

Type: Function
Default: null

opts.depsFor(input)

Receives an object and must return a promise yielding an array of its dependencies.

Type: Function
Default: null

Example extracting an array of dependencies from the contents of a package.json file.

const Deptrace = require('./');
const archy = require('archy');
const promise = require('bluebird');

const tracer = new Deptrace({
  depsFor: function (input) {
    var deps = input.dependencies || [];
    return promise.resolve(Object.keys(deps).map(function(depName) {
      return {
        name: depName,
        version: deps[depName]
      };  
    }))
  }
});
tracer.graph(require('./package.json')).then(function (graph) {
  console.log(archy(graph));
});

opts.resolve(dep, parents)

Receives each dependency gathered by depsFor, as well as an array of all parent dependencies. Must return a promise. This method is optional and can be used to resolve a more detailed represenstation of a dependency. (e.g. converting the name of a dependency in package.json to the actual package.json of that dependency).

Type: Function
Default: see source

Here is a naive example which can trace dependencies for any npm module for which all dependencies are on github:

const Deptrace = require('./');
const archy = require('archy');
const githubUrlFromGit = require('github-url-from-git');
const promise = require('bluebird');
const request = promise.promisify(require('request').get);
const tracer = new Deptrace({
  depsFor: Deptrace.packageJson('dependencies'),
  resolve: function (dep, parents) {
    return request('http://registry.npmjs.org/'+dep.name).
      get(1).
      then(JSON.parse).
      then(function(pkg) {
        return [
          'https://raw.githubusercontent.com',
          url.parse(githubUrlFromGit(pkg.repository.url)).path,
          '/master/package.json'
        ].join('');
      }).
      then(request).
      get(1).
      then(JSON.parse);
  }
});
var requestPkg = require('./node_modules/request/package.json');
tracer.graph(requestPkg).then(function (graph) {
  console.log(archy(graph));
});

opts.format(input, nodes)

This method can be used to format the result for each node of the graph after all of its direct dependencies have been resolved.

Type: Function
Default: see source

The default implementation formats the dependency graph to be compatible with archy (as follows):

{
  label: 'parent',
  nodes: [
    {
      label: 'child'
      nodes: [
        {
          label: 'subchild'
          nodes: []
        }
      ]
    }
  ]
}

graph(input)

Asynchronously trace a dependency graph for the provided input.

Deptrace.packageJson(field)

This helper can be used to generate a depsFor method that will extract an array of name/version dependencies from the specified dependency field in a package.json file. See example for opts.resolve(deps, parents).