Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback


The Deno Standard Library
Go to Latest
class MuxAsyncIterator
implements AsyncIterable<T>
import { MuxAsyncIterator } from "";

Multiplexes multiple async iterators into a single stream. It currently makes an assumption that the final result (the value returned and not yielded from the iterator) does not matter; if there is any result, it is discarded.


Example 1

import { MuxAsyncIterator } from "";

async function* gen123(): AsyncIterableIterator<number> {
  yield 1;
  yield 2;
  yield 3;

async function* gen456(): AsyncIterableIterator<number> {
  yield 4;
  yield 5;
  yield 6;

const mux = new MuxAsyncIterator<number>();
for await (const value of mux) {
  // ...
// ..


add(iterable: AsyncIterable<T>)

Add an async iterable to the stream.

iterate(): AsyncIterableIterator<T>

Returns an async iterator of the stream.

[Symbol.asyncIterator](): AsyncIterator<T>

Implements an async iterator for the stream.