Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/proc/legacy/deps.ts>tee

A high-level way to run child processes that is easy, flexible, powerful, and prevents resource leaks.
Go to Latest
function tee
import { tee } from "https://deno.land/x/proc@0.20.17/legacy/deps.ts";

Branches the given async iterable into the n branches.

Examples

Example 1

import { tee } from "https://deno.land/std@0.224.0/async/tee.ts";

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

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

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

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

Type Parameters

T
optional
N extends number = 2

Parameters

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

Returns

Tuple<AsyncIterable<T>, N>