Skip to content

trimWhileAsync

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

Defined in: packages/core/src/iterable/async/trim-while.ts:49

Yields the elements with any leading and trailing run satisfying predicate removed.

The async counterpart of trimWhile. The start-only case is dropWhileAsync, which this composes rather than duplicating.

Time complexity: O(n). Memory: O(longest matching run).

T

MaybeAsyncIterable<T>

The input iterable, sync or async.

MaybeAsyncPredicate<[T]>

Decides whether an element may be trimmed.

AsyncIterableIterator<T>

An iterator over the elements, leading and trailing matches removed.