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

mutexkit

v0.1.1

Published

Fair async Mutex and counting Semaphore with weighted permits, runExclusive, and AbortSignal support. Zero dependencies.

Readme

mutexkit

All Contributors

Fair async Mutex and counting Semaphore — weighted permits, runExclusive, and AbortSignal support. Zero dependencies.

CI npm version bundle size types license

JavaScript is single-threaded, but async still interleaves — two handlers can read-modify-write the same resource between awaits and corrupt it. mutexkit gives you a lock to serialize a critical section, and a semaphore to cap how many things touch a resource at once.

import { Mutex } from "mutexkit";

const mutex = new Mutex();

// No matter how many callers, the file is appended to one at a time, in order.
await mutex.runExclusive(() => appendLine(file, line));

Why mutexkit?

  • Mutex & Semaphore in one tiny package. Mutex for one-at-a-time; Semaphore(n) for at-most-n.
  • runExclusive does the right thing. Acquires, runs your function, and always releases — even if it throws.
  • Weighted permits. Charge more than one permit per acquire (e.g. memory-sized jobs against a budget).
  • Fair & cancellable. FIFO ordering so nobody starves; pass an AbortSignal to give up waiting. release() is idempotent — double-calling never over-releases.
  • Zero dependencies, ESM + CJS + types.

Install

npm install mutexkit
# or: pnpm add mutexkit  /  yarn add mutexkit  /  bun add mutexkit

API

Mutex

const mutex = new Mutex();

await mutex.runExclusive(async () => { /* critical section */ });

const release = await mutex.acquire();   // manual form
try { /* ... */ } finally { release(); }

mutex.tryAcquire();  // Release | null (null if held)
mutex.isLocked;      // boolean
mutex.pending;       // queued waiters

acquire / runExclusive accept { signal } to cancel a wait.

Semaphore

import { Semaphore } from "mutexkit";

const sem = new Semaphore(5); // at most 5 concurrent

await Promise.all(tasks.map((t) => sem.runExclusive(() => t())));

const release = await sem.acquire({ weight: 2 }); // take 2 permits
release();

sem.tryAcquire(2); // Release | null
sem.available;     // free permits
sem.pending;       // queued waiters

acquire / runExclusive accept { signal, weight }.

When to reach for which

| Need | Use | | ------------------------------------------------- | ---------------------------- | | Only one execution of a critical section at a time | Mutex | | At most N concurrent | Semaphore(N) | | Cap concurrency while mapping a list | runpool | | Cap rate (per second) | ratebucket |

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

MIT © Tung Tran