takeWhileInclusive
takeWhileInclusive<
T>(iterable,predicate):IterableIterator<T>
Defined in: packages/core/src/iterable/take-while-inclusive.ts:19
Yields elements for as long as predicate holds, including the first one
that fails it.
One of the two cases takeWhile gets wrong: it consumes the failing element
and discards it, which loses a terminator a caller needs — a delimiter, a
sentinel, the record that closed a run. Use beforeAndAfter when both sides
are wanted.
Time complexity: O(1) per element, over the prefix only.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”iterable
Section titled “iterable”Iterable<T>
The input iterable.
predicate
Section titled “predicate”Predicate<[T, number]>
Receives each element and its zero-based index. The first element it rejects is yielded, and iteration stops after it.
Returns
Section titled “Returns”IterableIterator<T>
An iterator over the prefix, terminator included.