Nightingale Posing Mischievously
    Wondering what’s next for npm?Check out our public roadmap! »

    npm-list-package-dependents

    1.0.0 • Public • Published

    Package Dependents

    NPM version Build Status Coverage Status Dependencies

    List a package's dependents.

    Installation

    $ npm install npm-list-package-dependents

    Usage

    var list = require( 'npm-list-package-dependents' );

    list( options, clbk )

    List a package's dependents.

    list( {'package': '<package>'}, clbk );
     
    function clbk( error, list ) {
        if ( error ) {
            throw error;
        }
        console.log( list );
        // returns ['<pkg1>','<pkg2>',...]
    }

    The function accepts the following options:

    • package: package name (required).
    • registry: registry. Default: 'registry.npmjs.org'.
    • port: registry port. Default: 443 (HTTPS) or 80 (HTTP).
    • protocol: registry protocol. Default: 'https'.

    To query an alternative registry, set the relevant options.

    var opts = {
        'package': '<package>',
        'registry': 'my.favorite.npm/registry',
        'port': 8080,
        'protocol': 'http'
    };
     
    list( opts, clbk );

    list.factory( options, clbk )

    Creates a reusable function.

    var get = list.factory( {'package': '<package>'}, clbk );
     
    get();
    get();
    get();
    // ...

    The factory method accepts the same options as list().

    Notes

    • When querying the main registry, the function only returns non-scoped public packages (see NPM issue #8244).

    Examples

    var list = require( 'npm-list-package-dependents' );
    var counts = require( 'npm-package-download-counts' );
     
    // Get the download counts for all dependent packages...
    var opts = {
        'package': 'dstructs-matrix'
    };
     
    list( opts, onList );
     
    function onList( error, list ) {
        var opts;
        if ( error ) {
            throw error;
        }
        opts = {
            'packages': list
        };
        counts( opts, onCounts );
    }
     
    function onCounts( error, counts ) {
        if ( error ) {
            throw error;
        }
        console.dir( counts );
    }

    To run the example code from the top-level application directory,

    $ DEBUG=* node ./examples/index.js

    CLI

    Installation

    To use the module as a general utility, install the module globally

    $ npm install -g npm-list-package-dependents

    Usage

    Usage: deppkgs [options] package
     
    Options:
     
      -h,  --help                Print this message.
      -V,  --version             Print the package version.
      -p,  --port port           Registry port. Default: 443 (HTTPS) or 80 (HTTP).
           --registry registry   Registry. Default: 'registry.npmjs.org'.
           --protocol protocol   Registry protocol. Default: 'http'.

    Notes

    • The package list is written to stdout as a newline-delimited string.

    Examples

    $ DEBUG=* deppkgs dstructs-matrix
    # compute-abs
    # compute-digamma
    # compute-erf
    # ...

    Tests

    Unit

    This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:

    $ make test

    All new feature development should have corresponding unit tests to validate correct functionality.

    Test Coverage

    This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

    $ make test-cov

    Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

    $ make view-cov

    Browser Support

    This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:

    $ make test-browsers

    To view the tests in a local web browser,

    $ make view-browser-tests

    License

    MIT license.

    Copyright

    Copyright © 2016. Athan Reines.

    Install

    npm i npm-list-package-dependents

    DownloadsWeekly Downloads

    3

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • avatar