# promise-all-limit

> limit the maximum number of concurrent tasks

Latest version **1.0.0** (published 2019-05-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise-all-limit
pnpm add promise-all-limit
yarn add promise-all-limit
bun add promise-all-limit
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-05-07 |
| First published | 2019-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zengming00@qq.com |
| Maintainers | zengming00 |
| Keywords | promise, all, limit |

## Links

- npm: https://www.npmjs.com/package/promise-all-limit
- Repository: https://github.com/zengming00/promise-all-limit
- Homepage: https://github.com/zengming00/promise-all-limit#readme
- Issues: https://github.com/zengming00/promise-all-limit/issues
- npm.io page: https://npm.io/package/promise-all-limit

## Dependencies (1)

- [promise-limit](https://npm.io/package/promise-limit.md) ^2.7.0

## 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.0 (latest) — 2019-05-07

## README

<a href="https://996.icu"><img src="https://img.shields.io/badge/link-996.icu-red.svg" alt="996.icu" /></a>
# promise-all-limit

nodejs, limit the maximum number of concurrent tasks

```sh
npm install promise-all-limit
```

```js
const promiseAllLimit = require('promise-all-limit');

function job_reject_b(name) {
    const text = `job ${name}`
    console.log('started', text)
    return new Promise(function (resolve, reject) {
        setTimeout(() => {
            if (name === 'b') {
                return reject(new Error('b reject'));
            }
            console.log('       ', text, 'finished')
            resolve(text);
        }, 100)
    })
}

async function test() {
    try {
        const jobs = ['a', 'b', 'c', 'd', 'e'];
        const concurrency = 3;
        const results = await promiseAllLimit(jobs, concurrency, function (item) {
            return job_reject_b(item);
        });
        console.log('results:', results)
    } catch (e) {
        console.log('---> err:', e.message);
    }
}

test();
```

will output:

```
started job a
started job b
started job c
        job a finished
started job d
        job c finished
started job e
---> err: b reject
        job d finished
        job e finished
```

# License
MIT

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