Skip to content

takeWhileAsync

takeWhileAsync<T>(iterable, predicate): AsyncIterableIterator<T>

Defined in: packages/core/src/iterable/async/take-while.ts:17

Yields elements from the start for as long as predicate holds, stopping at the first one it rejects.

The async counterpart of takeWhile. The predicate may itself be async.

Time complexity: O(1) per element, over the prefix only.

T

MaybeAsyncIterable<T>

The input iterable, sync or async.

MaybeAsyncPredicate<[T, number]>

Receives each element and its zero-based index. Yielding stops the first time it resolves false.

AsyncIterableIterator<T>

An iterator over the leading elements that satisfy predicate.