Skip to main content
Module

std/async/mod.ts>tee

Deno standard library
Go to Latest
function tee
import { tee } from "https://deno.land/std@0.101.0/async/mod.ts";

Branches the given async iterable into the n branches.

Example:

const gen = async function* gen() {
  yield 1;
  yield 2;
  yield 3;
}

const [branch1, branch2] = tee(gen());

(async () => {
  for await (const n of branch1) {
    console.log(n); // => 1, 2, 3
  }
})();

(async () => {
  for await (const n of branch2) {
    console.log(n); // => 1, 2, 3
  }
})();

Type Parameters

T
optional
N extends number = 2

Parameters

src: AsyncIterable<T>
optional
n: N = [UNSUPPORTED]

Returns

Tuple<AsyncIterable<T>, N>