Skip to content

trimEndWhile

trimEndWhile<T>(iterable, predicate): IterableIterator<T>

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

Yields the elements with any trailing run satisfying predicate removed.

The generic form of String.prototype.trimEnd. An element is only known to be trailing once something that fails predicate follows it, so a run of candidates is held back until then — a source ending in a long run of matches buffers that whole run.

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

T

Iterable<T>

The input iterable.

Predicate<[T]>

Decides whether an element may be trimmed.

IterableIterator<T>

An iterator over the elements, trailing matches removed.