# aggregate-async-iterator

> Aggregates several async iterators into one (zip)

Latest version **1.2.5** (published 2026-03-12) · 0BSD license · 0 weekly downloads

## Install

```sh
npm install aggregate-async-iterator
pnpm add aggregate-async-iterator
yarn add aggregate-async-iterator
bun add aggregate-async-iterator
```

## Health

**Score 70/100 (B)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.5 |
| Published | 2026-03-12 |
| First published | 2020-05-30 |
| Weekly downloads | 0 |
| License | 0BSD |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Maintainers | arlac77 |
| Keywords | aggregate, asynciterator, iterators, sequence, zip |

## Links

- npm: https://www.npmjs.com/package/aggregate-async-iterator
- Repository: https://github.com/arlac77/aggregate-async-iterator
- Homepage: https://github.com/arlac77/aggregate-async-iterator#readme
- Issues: https://github.com/arlac77/aggregate-async-iterator/issues
- npm.io page: https://npm.io/package/aggregate-async-iterator

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.2.5 (latest) — 2026-03-12
- 1.2.4 — 2026-02-10
- 1.2.3 — 2025-11-26
- 1.2.2 — 2025-05-10
- 1.2.1 — 2024-03-11
- 1.2.0 — 2024-02-12
- 1.1.16 — 2023-02-15
- 1.1.15 — 2022-08-20
- 1.1.14 — 2022-07-09
- 1.1.13 — 2022-06-08
- 1.1.12 — 2022-06-07
- 1.1.11 — 2022-06-02
- 1.1.10 — 2022-03-31
- 1.1.9 — 2022-01-27
- 1.1.8 — 2022-01-27
- … 9 more at https://npm.io/package/aggregate-async-iterator/versions

## README

[![npm](https://img.shields.io/npm/v/aggregate-async-iterator.svg)](https://www.npmjs.com/package/aggregate-async-iterator)
[![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)
[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
[![bundlejs](https://deno.bundlejs.com/?q=aggregate-async-iterator\&badge=detailed)](https://bundlejs.com/?q=aggregate-async-iterator)
[![downloads](http://img.shields.io/npm/dm/aggregate-async-iterator.svg?style=flat-square)](https://npmjs.org/package/aggregate-async-iterator)
[![GitHub Issues](https://img.shields.io/github/issues/arlac77/aggregate-async-iterator.svg?style=flat-square)](https://github.com/arlac77/aggregate-async-iterator/issues)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Faggregate-async-iterator%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/arlac77/aggregate-async-iterator/goto)
[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/aggregate-async-iterator/badge.svg)](https://snyk.io/test/github/arlac77/aggregate-async-iterator)

# aggregate-async-iterator

Aggregates several async iterators into one (zip)

# usage

```js
import { aggregateRoundRobin, aggregateFifo } from "aggregate-async-iterator";

async function* sequence(name, time = 100, num = 10) {
  for (let i = 0; i < num; i += 1) {
    yield new Promise(resolve => setTimeout(resolve(name + i), time));
  }
}

console.log("RR:");

for await (const r of aggregateRoundRobin([
    sequence("A", 100, 3),
    sequence("B", 35, 5)
  ])) {
  console.log(r);
}

console.log("FIFO:");

for await (const r of aggregateFifo([
    sequence("A", 100, 3),
    sequence("B", 35, 5)
  ])) {
  console.log(r);
}
```

Prints interleaved sequences

```txt
RR:
A0
B0
A1
B1
A2
B2
B3
B4
FIFO:
A0
B0
A1
B1
A2
B2
B3
B4
```

# API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

*   [aggregateFifo](#aggregatefifo)
    *   [Parameters](#parameters)
*   [aggregateRoundRobin](#aggregateroundrobin)
    *   [Parameters](#parameters-1)

## aggregateFifo

Aggregate items from sevaral async iterators into one.
Items are collected first in first out from the sources.
Whatever source comes first will be delivered first.

### Parameters

*   `sources` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<AsyncIterator\<any>>**&#x20;

Returns **AsyncIterable\<any>** items collected from all sources

## aggregateRoundRobin

Aggregate items from sevaral async iterators into one.
Items are collected round robin from the sources.
The 2nd. round of items will only be delivered after all sources
have delivered their 1st. round (or reached their end).

### Parameters

*   `sources` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<AsyncIterator\<any>>**&#x20;

Returns **AsyncIterable\<any>** items collected from all sources

# install

With [npm](http://npmjs.org) do:

```shell
npm install aggregate-async-iterator
```

# license

BSD-2-Clause

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