Skip to content

About

All tiny-* async utilities in one package. Drop-in replacements for p-limit, p-map, p-retry, p-queue.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

tiny-async

npm version npm downloads CI TypeScript License: MIT

All tiny-* async utilities in one package. Drop-in replacements for p-limit, p-map, p-retry, and p-queue that ship ESM + CJS.

import { pLimit, pMap, pRetry, PQueue } from "tiny-pasync";

One install. Four utilities. All dual-format, all typed, all zero-dep individually.

Install

npm install tiny-pasync

What's included

Export Replaces Docs
pLimit p-limit tiny-limit
pMap, pMapSkip p-map tiny-map
pRetry, AbortError p-retry tiny-retry
PQueue p-queue tiny-queue

Each utility is also available as a standalone package if you only need one.

Quick examples

Limit concurrency

import { pLimit } from "tiny-pasync";

const limit = pLimit(5);
const results = await Promise.all(urls.map((url) => limit(() => fetch(url))));

Map with concurrency

import { pMap } from "tiny-pasync";

const pages = await pMap(urls, (url) => fetch(url).then((r) => r.text()), {
  concurrency: 10,
});

Retry with backoff

import { pRetry } from "tiny-pasync";

const data = await pRetry(() => fetchFromUnreliableAPI(), { retries: 3 });

Task queue with priority

import { PQueue } from "tiny-pasync";

const queue = new PQueue({ concurrency: 2 });
await queue.add(() => processJob(1));
await queue.add(() => urgentJob(), { priority: 10 });
await queue.onIdle();

Why not just install the originals?

p-limit v4+, p-map v6+, p-retry v6+, and p-queue v8+ are all ESM-only. CommonJS projects that require() them get ERR_REQUIRE_ESM.

The tiny-* packages ship both ESM and CJS, include TypeScript types, and have zero dependencies. This meta-package re-exports everything from one import.

The tiny-* family

Package Replaces What it does
tiny-limit p-limit Concurrency limiter
tiny-map p-map Concurrent map with order
tiny-retry p-retry Retry with exponential backoff
tiny-queue p-queue Priority task queue
tiny-ms ms Parse/format durations
tiny-escape escape-string-regexp Escape regex chars
tiny-pasync all of the above One import for all async utils

Author

Made by ofershap

LinkedIn GitHub


If this saved you from ERR_REQUIRE_ESM, star the repo or open an issue if something breaks.


README built with README Builder

License

MIT © Ofer Shapira

About

All tiny-* async utilities in one package. Drop-in replacements for p-limit, p-map, p-retry, p-queue.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages