list-dependents
TypeScript icon, indicating that this package has built-in type declarations

2.2.2 • Public • Published

list-dependents

Lists all dependents of a project, using npm and ecosyste.ms

npm version npm downloads neostandard javascript style Module type: ESM Types in JS Follow @voxpelli@mastodon.social

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

EcosystemDependentsOptions

  • filter(meta: EcosystemDependentsMeta) => boolean – function given EcosystemDependentsMeta and should return true for the package to be included
  • loggerBunyanLite – a logger instance
  • maxAgenumber – the maximum age of latest release to include
  • maxPagesnumber – the maximum number of source pages to fetch (there are perPage items per page)
  • minDownloadsLastMonth = 400number – the minimum amount of downloads needed to be returned
  • perPage = 36number – how many items per page to lookup
  • skipPkgboolean – when set skips resolving package.json

Returns

An AsyncGenerator that yields EcosystemDependentsItem objects

fetchEcosystemPackage()

Uses the ecosyste.ms API to resolve a package

Syntax

fetchEcosystemPackage(name, [options]) => Promise<EcosystemDependentsItem|false|undefined>

Arguments

  • namestring – The name of the package to do the lookup for
  • optionsPackageLookupOptions – optional options

PackageLookupOptions

  • clientgot – a client to use for HTTP requests
  • ecosystemsClientgot – a client to use for HTTP requests to ecosyste.ms
  • dependentOnstring – ensure the package depends on this module. Only works when package.json is fetched.
  • filter(meta: EcosystemDependentsMeta) => boolean – function given EcosystemDependentsMeta and should return true for the package to be included
  • loggerBunyanLite– a logger instance
  • skipPkgboolean | (meta: EcosystemDependentsMeta) => boolean – when true skips resolving package.json
  • userAgentstring – an additional more specific user agent to preceed the built in one in the User-Agent header of requests

Returns

A promise resolving to false if the package is actively excluded, undefined if it couldn't be resolved and else EcosystemDependentsItem

createPackageFetchQueue()

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.

Syntax

const fetchPackage = createPackageFetchQueue([queueOptions]);
const package = await fetchPackage(name, [options]);

Arguments

PackageFetchQueueOptions

  • clientgot – a client to use for HTTP requests
  • loggerBunyanLite– a logger instance
  • userAgentstring – an additional more specific user agent to preceed the built in one in the User-Agent header of requests

Returns

A function equal to fetchEcosystemPackage except that the client, ecosystemClient, logger and userAgent is overriden by the values sent in when it was created

Types

DependentsMeta

export interface DependentsMeta {
  downloads: number;
  name: string;
}

DependentsItem

import type { NormalizedPackageJson } from 'read-pkg';

export interface DependentsItem extends DependentsMeta {
  pkg?: NormalizedPackageJson | undefined;
  targetVersion?: string | undefined,
}

EcosystemDependentsMeta

export interface EcosystemDependentsMeta extends DependentsMeta {
  dependentCount: number | undefined,
  firstRelease: string | undefined,
  latestRelease: string | undefined,
  latestVersion: string | undefined,
  repositoryUrl: string | undefined;
}

EcosystemDependentsItem

export interface EcosystemDependentsItem extends DependentsItem, EcosystemDependentsMeta {}

Similar modules

Readme

Keywords

none

Package Sidebar

Install

npm i list-dependents

Weekly Downloads

72

Version

2.2.2

License

MIT

Unpacked Size

32.3 kB

Total Files

33

Last publish

Collaborators

  • voxpelli