list-dependents
v1.0.1
Published
Lists all dependents of a project, using npm or ecosyste.ms
Downloads
198
Readme
list-dependents
Lists all dependents of a project, using npm and ecosyste.ms
Usage
Simple
import { fetchEcosystemDependents } from 'list-dependents';
const result = fetchEcosystemDependents(name);
for await (const { downloads, name, pkg } of fetchEcosystemDependents('npm-run-all2')) {
console.log(downloads, name, pkg.description);
}
Advanced
See examples/cli.js
API
fetchEcosystemDependents()
Uses the ecosyste.ms
API to resolve packages of dependents
Syntax
fetchEcosystemDependents(name, [options]) => AsyncGenerator<EcosystemDependentsItem>
Arguments
name
: The name of the package to do the lookup foroptions
: TypeEcosystemDependentsOptions
– optional options
Options
logger
– aBunyanLite
compatible logger instancemaxAge
– the maximum age of latest release to uincludemaxPages
– the maximum number of source pages to fetch (there areperPage
items per page)minDownloadsLastMonth = 400
– the minimum amount of downloads needed to be returnedperPage = 36
– how many items per page to lookupskipPkg
– when set skips resolvingpackage.json
Types
import type { NormalizedPackageJson } from 'read-pkg';
interface DependentsItem {
downloads: number;
name: string;
pkg?: NormalizedPackageJson | undefined,
}
interface EcosystemDependentsItem extends DependentsItem {
dependentCount: number | undefined,
firstRelease: string | undefined,
latestRelease: string | undefined,
}
fetchNpmDependents()
Uses the npm website, registry API and download count API to resolve packages of dependents
Syntax
fetchNpmDependents(name, [options]) => AsyncGenerator<DependentsItem>
Arguments
name
: The name of the package to do the lookup foroptions
: TypeNpmDependentsOptions
– optional options
Options
logger
– aBunyanLite
compatible logger instandemaxPages
– the maximum number of source pages to fetch (there are36
items per page)minDownloadsLastWeek = 100
– the minimum amount of downloads needed to be returnedskipPkg
– when set skips resolvingpackage.json
Types
import type { NormalizedPackageJson } from 'read-pkg';
interface DependentsItem = {
downloads: number;
name: string;
pkg?: NormalizedPackageJson | undefined,
}
fetchNpmDependentList()
Uses the npm website to resolve dependent names. Used internally by fetchNpmDependents()
Syntax
fetchNpmDependentList(name, [options]) => AsyncGenerator<string>
Arguments
name
: The name of the package to do the lookup foroptions
: TypeNpmDependentListOptions
– optional options
Options
logger
– aBunyanLite
compatible logger instandemaxPages
– the maximum number of source pages to fetch (there are36
items per page)
Similar modules
dependents
– usesnpm-dependants
together with the npm API and GitHub API to deliver a functionality similar tofetchEcosystemDependents()
/fetchNpmDependents()
list-installed
– sister module to this module – similar API but resolves locally installed modules rather than remote dependentsnpm-dependants
– similar in functionality tofetchNpmDependentList()