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

relinquish

v0.1.0

Published

Adapters that turn callbacks, event listeners, timers, and AbortControllers into `using`-ready disposables. Adopt Explicit Resource Management with the APIs you already have. Zero deps.

Readme

relinquish

npm MIT License

Adapters that turn callbacks, event listeners, timers, and AbortControllers into using-ready disposables. Adopt Explicit Resource Management with the APIs you already have. Zero deps.

The problem

Manual teardown is fragile: a forgotten clearTimeout, a listener that's never unbound, an AbortController that's never aborted. Each is a leak or a zombie callback. try/finally spreads cleanup across the function and is easy to skip under early returns or exceptions.

TypeScript 5.2 and modern Node ship using/await using and Symbol.dispose/Symbol.asyncDispose for deterministic cleanup — but almost nothing in the ecosystem exposes them yet. Timers, listeners, controllers, and ad-hoc teardown handles all still need manual cleanup.

Install

npm install relinquish
# or: pnpm add relinquish / yarn add relinquish

Requires Node >=20.11 and TypeScript with lib: ["esnext"] (includes esnext.disposable).

Use

import { listener, timer, aborter } from "relinquish";
import { EventEmitter } from "node:events";

const emitter = new EventEmitter();
using sub = listener(emitter, "data", onData);
using t = timer(setTimeout(tick, 1000));
using ac = aborter();
fetch(url, { signal: ac.signal });
// at end of scope: listener removed, timer cleared, controller aborted.

Compose multiple disposables with a stack — reverse-order, exactly once, errors aggregated:

import { stack, effect } from "relinquish";

using s = stack();
s.defer(() => closeDb());
s.use(effect(() => acquireLock(), (lock) => releaseLock(lock)));
// at end of scope: lock released, then db closed.

API

Disposable_ / AsyncDisposable_

interface Disposable_ { [Symbol.dispose](): void }
interface AsyncDisposable_ { [Symbol.asyncDispose](): Promise<void> }

Minimal disposable shapes. The underscore avoids colliding with the TS lib's Disposable.

effect(dispose) / effect(setup, dispose)

function effect(dispose: () => void): Disposable_;
function effect<T>(setup: () => T, dispose: (value: T) => void): Disposable_ & { value: T };

Wrap a teardown callback. The two-arg form runs setup() immediately, exposes .value, and passes it to dispose(value) on cleanup. Idempotent.

asyncEffect(dispose)

function asyncEffect(dispose: () => Promise<void>): AsyncDisposable_;

Async analogue of effect. For setup+dispose pairs, compose via asyncStack().defer(...).

listener(target, type, handler, options?)

Bind handler to type on target. Disposing calls the matching unbind. target is structural and auto-detected at registration: any object with addEventListener/removeEventListener (DOM EventTarget, AbortSignal, ...) OR on/off (Node EventEmitter). handler is any callable. options (optional) is passed through to both add and remove — required to unbind the right listener.

Returns Disposable_.

timer(id) / interval(id)

function timer(id: ReturnType<typeof setTimeout>): Disposable_;
function interval(id: ReturnType<typeof setInterval>): Disposable_;

Wrap a timer id. Disposing calls clearTimeout / clearInterval.

aborter(reason?)

function aborter(reason?: unknown): AbortController & Disposable_;

Returns a real AbortController augmented with [Symbol.dispose] that calls abort(reason). The .signal is standard; reason is forwarded on dispose.

stack() / asyncStack()

function stack(): DisposableStackLike;
function asyncStack(): AsyncDisposableStackLike;

interface DisposableStackLike extends Disposable_ {
  use<T extends Disposable_>(d: T): T;
  defer(fn: () => void): void;
  move(): DisposableStackLike;
}

Aggregate disposables. Disposal runs in reverse registration order, exactly once. On multiple disposal errors, throws SuppressedError(latest, AggregateError(rest)) when available, else AggregateError(all). move() returns a new stack that takes ownership; the original becomes disposed — subsequent use/defer/move on it throw. Prefers the platform's native DisposableStack / AsyncDisposableStack when present; falls back to a polyfill.

Non-goals

What relinquish does NOT do:

  • Does NOT reimplement the platform's DisposableStack. Prefers native when present.
  • Does NOT pool resources or reference-count them.
  • Does NOT add framework hooks or decorators.
  • Does NOT replace try/finally for non-disposable cleanup.

TypeScript note

Full type declarations ship in dist/. If you have noUnusedLocals enabled, prefix unused using bindings with _ (e.g., using _sub = ...) — TS does not exempt using declarations from the unused-locals check.

License

MIT