# @dwbinns/parallel

> Execute async jobs with specified parallelism

Latest version **2.0.0** (published 2022-03-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install @dwbinns/parallel
pnpm add @dwbinns/parallel
yarn add @dwbinns/parallel
bun add @dwbinns/parallel
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-03-05 |
| First published | 2021-09-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 2.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | dwbinns |

## Links

- npm: https://www.npmjs.com/package/@dwbinns/parallel
- Repository: https://github.com/dwbinns/parallel
- Issues: https://github.com/dwbinns/parallel/issues
- npm.io page: https://npm.io/package/@dwbinns/parallel

## Recent versions

- 2.0.0 (latest) — 2022-03-05
- 1.0.0 — 2021-09-05

## README

# Run tasks with limited parallelism

```js
import parallel from "@dwbinns/parallel";
import { setTimeout } from "timers/promises";

function run(id) {
  return async () => {
    console.log("Start", id);
    await setTimeout(10, id);
    console.log("End", id);
    return id;
  };
}

const queue = parallel(2);

const results = await Promise.all([
  queue(run(1)),
  queue(run(2)),
  queue(run(3)),
  queue(run(4)),
]);

console.log(results);
```

```
Start 1
Start 2
End 1
Start 4
End 2
Start 3
End 4
End 3
[ 1, 2, 3, 4 ]
```

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