voxpelli / list-dependents

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

list-dependents

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

npm version npm downloads js-semistandard-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 uinclude
  • 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

About

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

License:MIT License


Languages

Language:JavaScript 99.8%Language:Shell 0.2%