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 🙏

© 2024 – Pkg Stats / Ryan Hefner

required

v1.0.0

Published

traverse your script and identify dependencies from requires

Downloads

1,854

Readme

required Build Status

Identifies which modules and files your script is using.

example

var required = require('required');

required('/path/to/entry/source/file/js', function(err, deps) {
    // deps is an array of dependency objects
    // see the api section below for a description of the object
});

api

required(filename, [opt], cb)

Reads the filename and traverses all the dependencies.

The return result to callback is (err, details) where details is an array of dependencies for the file.

Each object in the array takes the following form:

{
    // the local name of the require
    // i.e. the string in your "require" statement
    id: 'local-require-name',

    // true if core module (i.e. events, cryto, etc)
    // core modules will not have any deps
    core: true | false

    // full path to the entry file for the module
    // this does not exist for builtin modules
    filename: '/path/to/require/from/project/file.js',

    // an array of the dependencies for the file
    // each object is of the same form as described above
    deps: [
        ...
    ]
},

opt is an optional options object with the following defaults

{
    // if true, then missing modules will be silently ignored.
    // useful if you don't care about some failed requires with native builds.
    // if you pass a function instead of true, the function will be invoked
    // with this signature: `yourFn(missingModuleName, parentSourceFilePath)`,
    // e.g. `ignoreMissing: function(name, parent) { /* ... */ }`
    ignoreMissing: false,

    // if true, include the source contents for each file in the results
    // in a "source" field
    includeSource: false,

    // optional function for required to use when resolving an id
    // function(id, parent, cb);
    // id is the string for the call to require
    // parent is an object describing the calling file { filename: String, paths: [] }
    // callback (err, '/path/to/resolved/file.js' [, ignore])
    // if ignore is true, required will not try to process the resulting path for deps
    resolve: null,

    // optional replacement for builtin detection of requires
    // called with the file source
    detective: null,
}

install

npm install required

tests

Run tests with npm test

Rebuild the golden files with npm run-script test-generate

Generate a coverage report (requires cover module) npm run-script coverage