Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 16 lines (11 sloc) 355 Bytes
type FindIndexCallback<T> = (value: T, index: number, array: T[]) => boolean;
export function findIndex<T>(array: T[], callback: FindIndexCallback<T>) {
const { length } = array;
for (let index = 0; index < length; index += 1) {
const value = array[index];
if (callback(value, index, array)) {
return index;
}
}
return -1;
}
You can’t perform that action at this time.