Function tee
- tee<T, N>(iterable, n?): Tuple<AsyncIterable<T>, N>
Type Parameters
Parameters
Returns Tuple<AsyncIterable<T>, N>
The tuple where each element is an async iterable.
Example: Usage
import { tee } from "@std/async/tee";
import { assertEquals } from "@std/assert";
const gen = async function* gen() {
yield 1;
yield 2;
yield 3;
};
const [branch1, branch2] = tee(gen());
const result1 = await Array.fromAsync(branch1);
assertEquals(result1, [1, 2, 3]);
const result2 = await Array.fromAsync(branch2);
assertEquals(result2, [1, 2, 3]);
Branches the given async iterable into the
nbranches.