@push-stream-std/push-many (0.0.7)
Installation
@push-stream-std:registry=https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/npm install @push-stream-std/push-many@0.0.7"@push-stream-std/push-many": "0.0.7"About this package
push-many
Combine multiple push sources into one, with dynamic source addition.
Published as @push-stream-std/push-many.
Synopsis
import { many } from '@push-stream-std/push-many';
import { values } from '@push-stream-std/push-values';
import { collect } from '@push-stream-std/push-collect';
const m = many();
m.add(values([1, 2]));
m.add(values([3, 4]));
m.cap();
m.pipe(collect((err, results) => {
console.log(results); // [1, 3, 2, 4] (round-robin order)
}));
Install
npm config set @push-stream-std:registry https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/
npm config set -- //hub.kl1.tenere.ai/api/packages/push-stream-std/npm/:_authToken "$PACKAGE_TOKEN"
npm install @push-stream-std/push-many
Description
Aggregates multiple push-stream sources into a single output using round-robin scheduling. Sources can be added dynamically via add() before or after piping. Once all sources are registered, calling cap() marks the set as complete — the stream ends when all sources have finished. This is useful for fan-in patterns where the full set of upstream sources is not known at creation time.
API
many(initialSources)
Creates a stream that combines multiple push-stream sources.
Parameters:
initialSources(Array, optional) — An array of push-stream sources to add immediately. If provided,cap()is called automatically after adding them.
Returns: A push-stream through with additional methods:
stream.add(source)
Dynamically adds a push-stream source to the combined output. Throws if called after cap() or after the stream has ended.
stream.cap()
Marks the set of sources as complete. No further sources may be added. The stream will end once all sources have ended.
stream.capped
Boolean property indicating whether cap() has been called.
Tests
npm test
Tests cover round-robin ordering, dynamic source addition, cap() semantics, backpressure propagation across sources, error handling, and end-on-all-complete behavior.
Requirements
Node.js 18 or later. ESM only.
License
MIT
Dependencies
Dependencies
| ID | Version |
|---|---|
| @push-stream-std/push-stream-base | * |