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 🙏

© 2026 – Pkg Stats / Ryan Hefner

qpass

v1.2.0

Published

Asynchronous function handler with adjustable concurrency

Readme

Qpass

Qpass is a lightweight promise-job queue for JavaScript/TypeScript. It runs jobs in cycles with configurable parallelism (batchSize) and reports progress after each cycle.

Platform support

  • Node.js ESM (import) via qpass
  • Node.js CommonJS (require) via qpass
  • Browser bundlers (Vite/Webpack/Rollup) via qpass
  • Browser script tag/global build via dist/qpass.js

Version is sourced from package.json at build time, so you only update it in one place.

Install

npm install qpass

Quick start

import Qpass from "qpass";

const queue = new Qpass({
    batchSize: 3,
    onProgress: ({ batchToProcess, itemsToProcess, completed }) => {
        console.log({ batchToProcess, itemsToProcess, completed });
    },
});

const jobs = [
    () => Promise.resolve("A"),
    () => Promise.resolve("B"),
    () => Promise.resolve("C"),
    () => Promise.resolve("D"),
];

queue.add(jobs);

Import by platform

Node.js ESM

import Qpass from "qpass";

Node.js CommonJS

const Qpass = require("qpass").default;

Browser bundler

import Qpass from "qpass";

Browser script tag (global)

Use the global build from your package output or CDN:

<script src="https://cdn.jsdelivr.net/npm/qpass/dist/qpass.js"></script>
<script>
    const queue = new Qpass();
</script>

API

new Qpass(options?)

new Qpass({
    breakWhenError?: boolean;
    batchSize?: number; // >= 1, default: 1
    onProgress?: (progress: {
        batchToProcess: number;
        itemsToProcess: number;
        completed: any[];
    }) => void;
})

Options

  • batchSize (default 1): number of jobs to run in parallel per cycle.
  • breakWhenError (default false): when true, queued jobs are cleared after an error is seen.
  • onProgress: called after each cycle finishes.

add(jobs)

add(jobs: (() => Promise<any>)[] | (() => Promise<any>)): string | string[]
  • Adds one or many jobs to the queue.
  • Starts processing automatically.
  • Returns the generated job id for a single job, or an array of ids for multiple jobs.

remove(id)

remove(id: string | number): boolean
  • Removes a pending queued job by its id.
  • Returns true when a queued job is removed, or false if the id was not found.
  • Does not stop jobs already in progress.

terminate()

terminate(): void
  • Clears all queued (not-yet-started) jobs.
  • Already running jobs continue until they settle.

Progress callback behavior

onProgress receives:

  • completed: results (or errors) from the cycle that just finished.
  • itemsToProcess: queued jobs still waiting to start.
  • batchToProcess: Math.ceil(itemsToProcess / batchSize).

Notes:

  • Progress is reported per cycle, not per individual job completion.
  • If you call add repeatedly (for example, inside a loop), the first cycle may be smaller than batchSize because processing starts immediately.

Error handling

Continue on error (breakWhenError: false)

const queue = new Qpass({
    breakWhenError: false,
    batchSize: 2,
    onProgress: ({ completed }) => {
        console.log(
            completed.map((x) => (x instanceof Error ? `Error: ${x.message}` : x))
        );
    },
});

queue.add([
    () => Promise.resolve("ok-1"),
    () => Promise.reject(new Error("failed-2")),
    () => Promise.resolve("ok-3"),
]);

Stop queueing after error (breakWhenError: true)

const queue = new Qpass({
    breakWhenError: true,
    batchSize: 3,
    onProgress: ({ itemsToProcess, completed }) => {
        console.log({ itemsToProcess, completed });
    },
});

queue.add([
    () => Promise.resolve("ok-1"),
    () => Promise.reject(new Error("failed-2")),
    () => Promise.resolve("ok-3"),
    () => Promise.resolve("queued-but-may-be-cleared"),
]);

With breakWhenError: true, Qpass clears jobs still waiting in the queue after an error is observed. Jobs already running in the same cycle still settle.

Practical pattern: queue all jobs at once

If you want predictable itemsToProcess values in onProgress, build the job array first and call add once:

const jobs = [];

for (let i = 1; i <= 14; i++) {
    jobs.push(() => Promise.resolve(`Job ${i}`));
}

queue.add(jobs);

License

ISC