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

@cancjs/toolbox-native

v1.0.0

Published

Promise timing/retry on native Promise (no cancellation).

Downloads

686

Readme


Introduction

The native twin of @cancjs/toolbox. Same helpers, same options, backed by the built-in Promise and with no cancellation.

Reach for it when a project wants the utility set without adopting cancelable promises, or in a library that should not force a promise implementation on its consumers.

Features

  • timing, control and rate limiting helpers on plain Promise
  • callback adapters (promisify, promisifyAll) with the same options as the cancelable twin
  • no dependencies

Getting Started

Installation

npm install @cancjs/toolbox-native

Core packages, @cancjs/promise and @cancjs/coroutine, follow strict semver and are safe on a caret pin, ^1. Everything else, the toolbox, fetch, decorators, axios and the adapters that follow, releases on a shared minor line that can carry a breaking change inside a minor, so pin those with a tilde, ~1.4 (pin the minor, not ~1.x, which npm expands to the same range as ^1). Full policy, including the deprecation and compatibility-floor rules: Versioning.

Usage

import { delay, retry, timeout } from '@cancjs/toolbox-native';

await delay(1000);

const report = await retry((attempt) => buildReport({ attempt }), {
  retries: 5,
  minTimeout: 200,
});

const quotes = await timeout(fetchQuotes(), 3000);

Description

The difference from the cancelable twin is what happens to work already in flight. Here nothing can be stopped: timeout rejects but the underlying promise runs to completion, a pending retry attempt finishes even after the returned promise has been abandoned, and a delay timer that nobody waits for still fires.

cancelify and signal generation (toAbortSignal, withSignal, createAbortSignal) have no meaning without cancellation and are twin-only; catchAbort, suppressAbort, catchTimeout, suppressTimeout, createCatchError, and createSuppressError are provided to filter errors on native promises (no cancellation handling).

Lazy promises

LazyPromise here has no cancel(). Deferred start, caching and the try/resolve/reject/ withResolvers/all/race/any/allSettled statics work the same as the cancelable twin; the only way to stop waiting on one is an AbortSignal:

import { createLazyPromise } from '@cancjs/toolbox-native';

const profile = createLazyPromise(loadProfile, { signal });

An already-aborted signal means the executor never runs at all; aborting while it is running rejects with the signal's reason. The underlying work itself keeps going. Only the waiting stops, because a native promise cannot be canceled. lazy and createLazyPromise wrap functions or promises.

API

delay(ms, options?), delay(input, ms, options?), minDelay(input, ms, options?), timeout(ms, options?), timeout(input, ms?, options?), waitFor(condition, options?), retry(input, options?), debounce(fn, ms, options?), throttle(fn, ms, options?), defer(options?), promisify(fn, options?), promisifyAll(source, options?), catchAbort(promiseOrError), suppressAbort(promiseOrError), catchTimeout(promiseOrError), suppressTimeout(promiseOrError), createCatchError(...matchers), createSuppressError(...matchers), AbortError, isAbortError(error), TimeoutError, isTimeoutError(error), LazyPromise, LazyPromise.try(fn, ...args), createLazyPromise(x, options?), lazy(run), isLazyPromise(value).

ms is a number of milliseconds or a [min, max] tuple, and is always the last positional argument before options. Option shapes are identical to @cancjs/toolbox, minus the cancelable promise options.

Compatibility

Node.js 18 and later, current browsers, TypeScript 4.2 and later. Ships CJS, ESM and UMD builds from ES5-targeted source, same as the rest of the ecosystem.

Documentation

Contributing

You are welcome to participate through issues and pull requests!

License

MIT