teeAsync
teeAsync<
T>(iterable,count?):AsyncIterableIterator<T,any,any>[]
Defined in: packages/core/src/iterable/async/tee.ts:24
Fans one iterable out to count independent iterators over the same
elements.
The async counterpart of tee. Anything one branch has read that another has
not yet reached is buffered — the span between the slowest and the fastest
consumer, and nothing more.
Branches may be advanced concurrently. A pull from the source is shared: branches that need the same not-yet-read element all await the one in-flight read rather than issuing their own, so the source is never advanced twice for one element.
Time complexity: O(1) amortised per element per branch. Memory: O(span).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”iterable
Section titled “iterable”The iterable to fan out, sync or async.
count?
Section titled “count?”number = 2
How many branches to produce. Must be a non-negative integer.
Returns
Section titled “Returns”AsyncIterableIterator<T, any, any>[]
One iterator per branch, each yielding every element of the source.
Throws
Section titled “Throws”If count is not a non-negative integer.