# @node-libraries/promise-limit

> Limits the maximum number of asynchronous processes that can be executed

Latest version **1.0.5** (published 2025-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @node-libraries/promise-limit
pnpm add @node-libraries/promise-limit
yarn add @node-libraries/promise-limit
bun add @node-libraries/promise-limit
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2025-06-19 |
| First published | 2021-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | SoraKumo |
| Maintainers | sora_kumo |
| Keywords | typescript, promise, parallel, limit |

## Links

- npm: https://www.npmjs.com/package/@node-libraries/promise-limit
- Repository: https://github.com/SoraKumo001/promise-parallels
- Homepage: https://github.com/SoraKumo001/promise-parallels#readme
- Issues: https://github.com/SoraKumo001/promise-parallels/issues
- npm.io page: https://npm.io/package/@node-libraries/promise-limit

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2025-06-19
- 1.0.4 — 2023-11-12
- 1.0.2 — 2023-01-30
- 1.0.1 — 2022-04-29
- 1.0.0 — 2021-09-12

## README

# @node-libraries/promise-limit

[![](https://img.shields.io/npm/l/@node-libraries/promise-limit)](https://www.npmjs.com/package/@node-libraries/promise-limit)
[![](https://img.shields.io/npm/v/@node-libraries/promise-limit)](https://www.npmjs.com/package/@node-libraries/promise-limit)
[![](https://img.shields.io/npm/dw/@node-libraries/promise-limit)](https://www.npmjs.com/package/@node-libraries/promise-limit)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/SoraKumo001/promise-parallels)

Limits the maximum number of asynchronous processes that can be executed.  
The number of executions is controlled at the loop stage, so no memory is wasted in the queue.

## usage

- `promiseLimit()` to create an instance
- `add()` to store Promise
- `wait()` waits for a specified maximum number
- `all()` waits for remaining processes

```ts
import { promiseLimit } from '@node-libraries/promise-limit';
const main = async () => {
  const ps = promiseLimit();
  for (let i = 0; i < 10; i++) {
    // Execute a random exit process and save the Promise
    ps.add(new Promise((resolve) => setTimeout(() => resolve(i), Math.random() * 100)));
    // Specify the maximum number of parallel execution and wait
    // Return value false: the process has not finished within the limit
    // Return index of the process returned by resolve
    const v = await ps.wait(5);
    console.log(`${i}:${v}`); // Number of loops: display the finished function
  }
  // wait for remaining processing if the loop exits with less than 5 in parallel
  (await ps.all()).forEach((v) => console.log(`*:${v}`));
};

main();
```

## Execution result

```sh
0:false
1:false
2:false
3:false
4:3
5:1
6:2
7:4
8:0
9:6
*:5
*:7
*:8
*:9
```

---
_Source: https://npm.io/package/@node-libraries/promise-limit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
