MCPcopy Create free account
hub / github.com/activejs/activejs / findIndexBackwards

Function findIndexBackwards

packages/core/src/utils/funcs.ts:221–236  ·  view source on GitHub ↗
(
  array: Array<T>,
  predicate: (value: T, index: number, obj: T[]) => boolean,
  fromIndex?: number
)

Source from the content-addressed store, hash-verified

219 * @internal please do not use.
220 */
221export function findIndexBackwards<T>(
222 array: Array<T>,
223 predicate: (value: T, index: number, obj: T[]) => boolean,
224 fromIndex?: number
225): number {
226 let i = isValidIndex(fromIndex)
227 ? Math.max(0, Math.min(fromIndex, array.length - 1))
228 : array.length - 1;
229 while (i > -1) {
230 if (predicate(array[i], i, array)) {
231 return i;
232 }
233 --i;
234 }
235 return -1;
236}
237
238/**
239 * @internal please do not use.

Callers 3

goToNonNilValueMethod · 0.90
extras.spec.tsFile · 0.90

Calls 2

isValidIndexFunction · 0.85
predicateFunction · 0.85

Tested by

no test coverage detected