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

@plinthjs/concurrency

v0.1.0

Published

Mason concurrency helpers (the Laravel Illuminate\Concurrency equivalent).

Readme

@plinthjs/concurrency

Mason's concurrency helpers, the Illuminate\Concurrency equivalent. Run a batch of tasks at once and collect the results in the same shape you passed in (run), or schedule work to happen after the current tick, fire-and-forget (defer). Dependency-free: it uses Node built-ins only.

Two drivers ship: AsyncDriver (the default, cooperative overlap on the event loop, ideal for I/O fan-out) and WorkerDriver (true parallelism on node:worker_threads, for CPU-bound work).

Install

npm install @plinthjs/concurrency

Usage

import { Concurrency } from '@plinthjs/concurrency'

// An array batch resolves to an array, in the same order.
const [user, orders] = await Concurrency.run([() => fetchUser(1), () => fetchOrders(1)])

// A record batch resolves to a record, with the same keys.
const stats = await Concurrency.run({
  users: () => countUsers(),
  orders: () => countOrders(),
})
stats.users // number

// If any task throws, run() rejects with that error.

Tasks that each await independent I/O genuinely overlap, so a batch finishes in about the time of its slowest task rather than the sum.

Deferred work

defer schedules a batch to run after the current tick. Its results are discarded and its errors are swallowed, so a failing deferred task never crashes the request. The returned handle lets you (or a test) force the run and wait for it:

const handle = Concurrency.defer([() => recordAnalytics(event), () => warmCache()])

await handle.invoke() // runs now if not started yet; never rejects, idempotent

Worker threads

For CPU-bound work, use the worker driver. A worker runs in a separate JS realm, so its tasks must be self-contained: build each one with workerJob(task, payload), where task captures no outer variables and payload (and the result) are structured-cloneable.

import { WorkerDriver, workerJob } from '@plinthjs/concurrency'

const workers = new WorkerDriver({ timeoutMs: 5_000 }) // optional per-job timeout

const results = await workers.run({
  sum: workerJob((p: { a: number; b: number }) => p.a + p.b, { a: 2, b: 3 }),
  product: workerJob((p: { a: number; b: number }) => p.a * p.b, { a: 2, b: 3 }),
})
// { sum: 5, product: 6 }

Referencing a captured variable inside a worker task throws a ReferenceError in the worker, which surfaces as a rejected run.

The manager

Concurrency is a process-wide ConcurrencyManager on the async driver. Build your own for a different default, a worker timeout, or custom drivers:

import { AsyncDriver, ConcurrencyManager } from '@plinthjs/concurrency'

const manager = new ConcurrencyManager({ default: 'async', workerTimeoutMs: 10_000 })

manager.driver() // the default driver (cached after first use)
manager.driver('worker') // the WorkerDriver
manager.extend('manual', () => new AsyncDriver({ schedule: () => {} })) // returns the manager

manager.driver('missing') // throws: Concurrency driver [missing] is not defined.

AsyncDriver accepts an injectable schedule function (defaulting to queueMicrotask), so tests can control exactly when deferred work fires.