npm-list-package-dependents v1.0.0
Package Dependents
List a package's dependents.
Installation
$ npm install npm-list-package-dependentsUsage
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) or80(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
functiononly 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.jsCLI
Installation
To use the module as a general utility, install the module globally
$ npm install -g npm-list-package-dependentsUsage
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
stdoutas a newline-delimitedstring.
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 testAll 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-covIstanbul creates a ./reports/coverage directory. To access an HTML version of the report,
$ make view-covBrowser 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-browsersTo view the tests in a local web browser,
$ make view-browser-testsLicense
Copyright
Copyright © 2016. Athan Reines.