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

abort-controller-lite

v1.0.0

Published

Lightweight abort controller for async operations

Readme

abort-controller-lite

npm Package Compressed Minified Size

Ultra‑small (no globals, no heavy polyfill machinery) subset of AbortController / AbortSignal for runtimes missing the standard.

Targets:

  • QuickJS / embed engines
  • WeChat Mini Programs
  • Older Node (<14.17) or minimal sandboxes

Differences & Caveats

Not a drop‑in polyfill. It’s intentionally smaller and simpler. Key differences from the web standard:

  • No global patching: this library never defines or mutates global AbortController/AbortSignal; import what you need.

    • AbortControllerAbortControllerLite (interface AbortControllerLike).
    • AbortSignalAbortSignalLite (interface AbortSignalLike).
  • Event model

    • No EventTarget. Listeners are plain functions, invoked as listener.call(signal) with no Event object.
    • No onabort property, no options (once, signal, capture, etc.) to addEventListener, no dispatchEvent.
    • After the first abort we clear listeners to save memory; manual re‑dispatch isn’t supported. Effectively behaves like { once: true } because an abort happens at most once and listeners are removed.
  • Errors and reason

    • We use lightweight Error subclasses (AbortError, TimeoutError), not DOMException.
    • throwIfAborted() throws the stored reason as‑is; avoid relying on instanceof DOMException. Prefer checking by name (e.g., err instanceof Error && err.name === 'AbortError').
  • AbortSignalLite.any(iterable) memory semantics

    • Immediate: if any input is already aborted, the result aborts immediately with that reason.
    • Native engines maintain internal weak source/dependent lists so combined signals don’t keep inputs alive and vice‑versa.
    • In pure JS we can’t mirror that precisely: because WeakSet is not iterable, we must keep strong references to sources and dependents and unlink them carefully to avoid leaks. While WeakRef and FinalizationRegistry could approximate an “iterable weak set”, they add complexity and overhead we avoid in this lightweight library, especially since those APIs are often unavailable or unreliable in our target environments.
    • Consequence: if you drop all references to the combined signal before any source aborts, the source signals still hold internal references that keep the combined signal (and its captured arrays) alive. Those references are only cleared when one of the sources aborts.
    • Practical guidance: use any() for short‑lived operations; avoid creating many long‑lived combined signals.
  • AbortSignalLite.timeout(ms)

    • Uses a regular setTimeout; in Node it is not unref’d, so it can keep the event loop alive until it fires. If you need unref, prefer native AbortSignal.timeout (Node 18+) or roll your own per‑env helper.
  • Listener error handling

    • If a listener throws, we rethrow it asynchronously (setTimeout) to avoid breaking other listeners.
    • Contrast: DOM event dispatch continues other listeners and reports the error (it does not throw to the dispatchEvent call site). Our rethrow is also non‑blocking for peers but surfaces as an async uncaught error; timing/visibility differs from browsers.
  • Types and modules

    • ESM‑only package. Use import syntax; require() isn’t supported.
    • Public types are AbortControllerLike and AbortSignalLike — lightweight subsets of the standard API. A parameter typed AbortSignalLike is type‑compatible with the native AbortSignal; this is compile‑time only and does not guarantee identical runtime behavior or capabilities.
    • TypeScript flags direct construction (new AbortSignalLite()) as a type error, but nothing prevents it at runtime. The web standard throws here; we rely on discipline — stick to signals from the controller or the static helpers for the intended lifecycle.

If you need exact spec behavior (DOMException types, EventTarget, GC semantics of any, timer unref, etc.), use the platform’s built‑ins where available.

License

MIT