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

Function findIndex

packages/core/src/utils/funcs.ts:203–216  ·  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

201 * @internal please do not use.
202 */
203export function findIndex<T>(
204 array: Array<T>,
205 predicate: (value: T, index: number, obj: T[]) => boolean,
206 fromIndex?: number
207): number {
208 let i = isValidIndex(fromIndex) ? Math.max(0, Math.min(fromIndex, array.length - 1)) : 0;
209 while (i < array.length) {
210 if (predicate(array[i], i, array)) {
211 return i;
212 }
213 ++i;
214 }
215 return -1;
216}
217
218/**
219 * @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