beforeAndAfterAsync
beforeAndAfterAsync<
T>(iterable,predicate): [AsyncIterableIterator<T,any,any>,AsyncIterableIterator<T,any,any>]
Defined in: packages/core/src/iterable/async/before-and-after.ts:22
Splits an iterable at the first element failing predicate, returning the
prefix and the remainder as two iterators over the same source.
The async counterpart of beforeAndAfter. The two share one underlying
iterator, so the first must be consumed before the second. Reading the
second early drains the first silently; abandoning the first part-way makes
the second resume from wherever the source was left, with no boundary
element.
Time complexity: O(1) per element. Memory: O(1).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”iterable
Section titled “iterable”The input iterable, sync or async.
predicate
Section titled “predicate”MaybeAsyncPredicate<[T, number]>
Receives each element and its zero-based index.
Returns
Section titled “Returns”[AsyncIterableIterator<T, any, any>, AsyncIterableIterator<T, any, any>]
The leading elements that satisfy predicate, then the rest
starting at the first that does not.