Skip to content

takeAsync

takeAsync<T>(iterable, count): AsyncIterableIterator<T>

Defined in: packages/core/src/iterable/async/take.ts:16

Yields at most the first count elements, then stops.

The async counterpart of take. The source is closed as soon as the quota is met, so taking from an endless stream terminates.

Time complexity: O(count).

T

MaybeAsyncIterable<T>

The input iterable, sync or async.

number

How many elements to yield. Must be a non-negative integer.

AsyncIterableIterator<T>

An iterator over the leading elements.

If count is not a non-negative integer.