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

all-package-names

v2.0.897

Published

Get all NPM package names

Downloads

46,464

Readme

Get all NPM package names.

Includes a JSON file of all NPM package names at the time of last publish, but also allows for syncing with latest packages.

Installation

yarn add all-package-names
npm install all-package-names

API

Programmatic Usage:

import { load, sync } from "all-package-names";

// Load from an existing sync (included on install)

load().then(({ packageNames }) => {
  console.log(packageNames); // array of all package names on npm
});

// Sync and return new package names

sync().then(({ packageNames }) => {
 console.log(packageNames); // array of all package names on npm
});

// Load with a maxAge of 1 minute

load({ maxAge: 60000 }).then(({ packageNames }) => {
  console.log(packageNames); // array of all package names on npm
});

// Sync with a maxAge of 1 minute

sync({ maxAge: 60000 }).then(({ packageNames }) => {
 console.log(packageNames); // array of all package names on npm
});

Basic Types:

import { load, sync, LoadOptions, SyncOptions, Save, State, StateHook } from "all-package-names";

function load({ maxAge }: LoadOptions): Promise<Save>

function sync({ maxAge }: LoadOptions = {}) => Promise<Save>;

type LoadOptions = {
  /**
   * Maximum milliseconds after a sync to avoid re-syncing
   */
   maxAge?: number;
};

type Save = {
  /**
   * Index of last package synced
   */
  since: number;
  /**
   * Timestamp of last sync
   */
  timestamp: number;
  /**
   * Array of package names
   */
  packageNames: string[];
};

State Hooks:

import { sync, LoadOptions, SyncOptions, Save, State, StateHook } from "all-package-names";

function sync({ onData, onStart, onEnd, maxAge }: SyncOptions = {}) => Promise<Save>;

type SyncOptions = {
  onStart?: StateHook;
  onData?: StateHook;
  onEnd?: StateHook;
} & LoadOptions;

type StateHook = (state: State) => void;

type State = {
  /**
   * Starting package sync index
   */
  start: number;
  /**
   * Current package sync index
   */
  index: number;
  /**
   * Ending package sync index
   */
  end: number;
  /**
   * Percentage of sync completed
   */
  progress: number;
  /**
   * Milliseconds since sync began
   */
  elapsed: number;
  /**
   * Set of package names that have been added
   */
  packageNames: Set<string>;
};

CLI Usage:

yarn all-package-names --help

Usage: all-package-names [options] [command]

Options:
  -v --version    output the version number
  -h, --help      display help for command

Commands:
  sync [options]  Sync latest packages from NPM
  help [command]  display help for command

Sync:

yarn all-package-names sync --help

Sync latest packages from NPM.

Usage: all-package-names sync [options]

Sync latest packages from NPM

Options:
  -m --max-age [milliseconds]  Maximum milliseconds after a sync to avoid re-syncing
  -h, --help                   display help for command

Commander Plugins:

Add all-package-names commands to any commander program:

import { program } from "commander";
import { syncCommand } from "all-package-names";

syncCommand(program);

MIT

Related Packages