npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

list-dependents

v2.2.2

Published

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

Downloads

925

Readme

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