Return the list of dependents for a package from GitHub.
var dependents = require( '@stdlib/_tools/github/dependents' );Returns the list of dependents for a package from GitHub according to a repository slug (:owner/:repo).
dependents( 'stdlib-js/stdlib', clbk );
function clbk( error, data ) {
if ( error ) {
throw new Error( error.message );
}
console.log( JSON.stringify( data ) );
}The function accepts the following options:
- type: dependency type. Must be either
'repository'or'package'. Default:'repository'. - useragent: user agent
string.
By default, the function returns the list of repository dependents. To return the list of package dependents, set the type option.
var opts = {
'type': 'package'
};
dependents( 'stdlib-js/stdlib', opts, clbk );
function clbk( error, data ) {
if ( error ) {
throw new Error( error.message );
}
console.log( JSON.stringify( data ) );
}Each element of the returned array is an object having the following properties:
-
owner: repository owner.
-
type: owner type. Either
'user'or'organization'. -
repos: list of repositories/packages which depend on
slug. Each element is a 3-element array comprised as follows:[ <repository_name>, <number_of_stars>, <number_of_forks> ]
var dependents = require( '@stdlib/_tools/github/dependents' );
dependents( 'stdlib-js/random-base-mt19937', onResponse );
function onResponse( error, data ) {
if ( error ) {
console.error( error.message );
return;
}
console.log( JSON.stringify( data, ' ', 2 ) );
}Usage: ghdependents [options] slug
Options:
-h, --help Print this message.
-V, --version Print the package version.
--type type Dependency type. Default: repository.
-ua, --useragent ua User agent.$ ghdependents stdlib-js/random-base-mt19937