Lists all dependents of a project, using npm and ecosyste.ms
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);
}
See examples/cli.js
Uses the ecosyste.ms
API to resolve packages of dependents
fetchEcosystemDependents(name, [options]) => AsyncGenerator<EcosystemDependentsItem>
-
name
–string
– the name of the package to do the lookup for -
options
–EcosystemDependentsOptions
– optional options
-
filter
–(meta: EcosystemDependentsMeta) => boolean
– function givenEcosystemDependentsMeta
and should returntrue
for the package to be included -
logger
–BunyanLite
– a logger instance -
maxAge
–number
– the maximum age of latest release to include -
maxPages
–number
– the maximum number of source pages to fetch (there areperPage
items per page) -
minDownloadsLastMonth = 400
–number
– the minimum amount of downloads needed to be returned -
perPage = 36
–number
– how many items per page to lookup -
skipPkg
–boolean
– when set skips resolvingpackage.json
An AsyncGenerator
that yields EcosystemDependentsItem
objects
Uses the ecosyste.ms
API to resolve a package
fetchEcosystemPackage(name, [options]) => Promise<EcosystemDependentsItem|false|undefined>
-
name
–string
– The name of the package to do the lookup for -
options
–PackageLookupOptions
– optional options
-
client
–got
– a client to use for HTTP requests -
ecosystemsClient
–got
– a client to use for HTTP requests to ecosyste.ms -
dependentOn
–string
– ensure the package depends on this module. Only works whenpackage.json
is fetched. -
filter
–(meta: EcosystemDependentsMeta) => boolean
– function givenEcosystemDependentsMeta
and should returntrue
for the package to be included -
logger
–BunyanLite
– a logger instance -
skipPkg
–boolean | (meta: EcosystemDependentsMeta) => boolean
– whentrue
skips resolvingpackage.json
-
userAgent
–string
– an additional more specific user agent to preceed the built in one in theUser-Agent
header of requests
A promise resolving to false
if the package is actively excluded, undefined
if it couldn't be resolved and else EcosystemDependentsItem
Returns a fetchEcosystemPackage
equivalent that enforces a maximum concurrent fetches to npm + shares the back-off between all fetches, respecting the Retry-After
response headers.
const fetchPackage = createPackageFetchQueue([queueOptions]);
const package = await fetchPackage(name, [options]);
-
queueOptions
–PackageFetchQueueOptions
– optional options
-
client
–got
– a client to use for HTTP requests -
logger
–BunyanLite
– a logger instance -
userAgent
–string
– an additional more specific user agent to preceed the built in one in theUser-Agent
header of requests
A function equal to fetchEcosystemPackage
except that the client
, ecosystemClient
, logger
and userAgent
is overriden by the values sent in when it was created
export interface DependentsMeta {
downloads: number;
name: string;
}
import type { NormalizedPackageJson } from 'read-pkg';
export interface DependentsItem extends DependentsMeta {
pkg?: NormalizedPackageJson | undefined;
targetVersion?: string | undefined,
}
export interface EcosystemDependentsMeta extends DependentsMeta {
dependentCount: number | undefined,
firstRelease: string | undefined,
latestRelease: string | undefined,
latestVersion: string | undefined,
repositoryUrl: string | undefined;
}
export interface EcosystemDependentsItem extends DependentsItem, EcosystemDependentsMeta {}
-
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 dependents -
npm-dependants
– similar in functionality tofetchNpmDependentList()