mux()
mux<
T>(inputs):AsyncIterable<Iteratee<T>>
Defined in: src/Mux.ts:74
Creates an async iterable that merges several inputs into one.
Items are emitted as they arrive, so the order across inputs is not defined; the order within each input is kept.
If an input throws, the iteration ends with that error and the other inputs stop at their next item.
Type Parameters
T
T extends Iter<unknown>
Parameters
inputs
T[]
the sources to merge
Returns
AsyncIterable<Iteratee<T>>
an async iterable of the items of all inputs
Example
const merged = await chain(
mux([
[1, 2, 3],
[10, 20, 30],
]),
).toArray();
// the six items arrive in some interleaving;
// merged.filter((n) => n < 10) => [1, 2, 3]
// merged.filter((n) => n >= 10) => [10, 20, 30]