Skip to content

lastIndicesWhere

lastIndicesWhere<T>(iterable, predicate): IterableIterator<number>

Defined in: packages/core/src/iterable/indices-where.ts:46

Yields the zero-based index of every element satisfying predicate, scanning from the end.

Indices are still counted from the start — only the order they are yielded in is reversed, so the result is indicesWhere reversed.

An iterable has no end to start from, so a non-array source is materialised first and the whole of it is held in memory. An array is walked backwards in place.

Time complexity: O(n), with O(n) memory for a non-array source and O(1) for an array.

T

Iterable<T>

The input iterable.

Predicate<[T, number]>

Receives each element and its zero-based index.

IterableIterator<number>

An iterator over the matching indices, descending.