Skip to content

takeWhileInclusiveAsync

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

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

Yields elements for as long as predicate holds, including the first one that fails it.

The async counterpart of takeWhileInclusive, and one of the two cases takeWhileAsync gets wrong: it consumes the failing element and discards it, which loses a terminator a caller needs.

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. The first element it rejects is yielded, and iteration stops after it.

AsyncIterableIterator<T>

An iterator over the prefix, terminator included.