# @vates/async-each

> Run async fn for each item in (async) iterable

Latest version **1.0.3** (published 2026-04-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install @vates/async-each
pnpm add @vates/async-each
yarn add @vates/async-each
bun add @vates/async-each
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2026-04-24 |
| First published | 2021-11-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.10 |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 988 |
| Author | Vates SAS |
| Maintainers | mpiton, florent.beauchamp, mathieura, julien-f, marsaud, pdonias, tgoettelmann, enishowk, b-nollet, mlssfrncjrg, arnogues, joris-k, elise-f, nathanael-h, olivier.f, pierre.brunet289 |
| Keywords | array, async, collection, each, for, foreach, iterable, iterator |

## Links

- npm: https://www.npmjs.com/package/@vates/async-each
- Repository: https://github.com/vatesfr/xen-orchestra
- Homepage: https://github.com/vatesfr/xen-orchestra/tree/master/@vates/async-each
- Issues: https://github.com/vatesfr/xen-orchestra/issues
- npm.io page: https://npm.io/package/@vates/async-each

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2026-04-24
- 1.0.2 — 2026-03-27
- 1.0.1 — 2025-10-06
- 1.0.0 — 2022-07-28
- 0.1.0 — 2021-11-29

## README

<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->

# @vates/async-each

[![Package Version](https://badgen.net/npm/v/@vates/async-each)](https://npmjs.org/package/@vates/async-each) ![License](https://badgen.net/npm/license/@vates/async-each) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@vates/async-each)](https://bundlephobia.com/result?p=@vates/async-each) [![Node compatibility](https://badgen.net/npm/node/@vates/async-each)](https://npmjs.org/package/@vates/async-each)

> Run async fn for each item in (async) iterable

## Install

Installation of the [npm package](https://npmjs.org/package/@vates/async-each):

```sh
npm install --save @vates/async-each
```

## Usage

### `asyncEach(iterable, iteratee, [opts])`

Executes `iteratee` in order for each value yielded by `iterable`.

Returns a promise wich rejects as soon as a call to `iteratee` throws or a promise returned by it rejects, and which resolves when all promises returned by `iteratee` have resolved.

`iterable` must be an iterable or async iterable.

`iteratee` is called with the same `this` value as `asyncEach`, and with the following arguments:

- `value`: the value yielded by `iterable`
- `index`: the 0-based index for this value
- `iterable`: the iterable itself

`opts` is an object that can contains the following options:

- `concurrency`: a number which indicates the maximum number of parallel call to `iteratee`, defaults to `10`. The value `0` means no concurrency limit.
- `signal`: an abort signal to stop the iteration
- `stopOnError`: whether to stop iteration of first error, or wait for all calls to finish and throw an `AggregateError`, defaults to `true`

```js
import { asyncEach } from '@vates/async-each'

const contents = []
await asyncEach(
  ['foo.txt', 'bar.txt', 'baz.txt'],
  async function (filename, i) {
    contents[i] = await readFile(filename)
  },
  {
    // reads two files at a time
    concurrency: 2,
  }
)
```

## Contributions

Contributions are _very_ welcomed, either on the documentation or on
the code.

You may:

- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
  you've encountered;
- fork and create a pull request.

## License

[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

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