remeda
Version:
A utility library for JavaScript and Typescript.
50 lines • 2.1 kB
TypeScript
//#region src/findLastIndex.d.ts
/**
* Iterates the array in reverse order and returns the index of the first
* element that satisfies the provided testing function. If no elements satisfy
* the testing function, -1 is returned.
*
* See also `findLast` which returns the value of last element that satisfies
* the testing function (rather than its index).
*
* @param data - The items to search in.
* @param predicate - A function to execute for each element in the array. It
* should return `true` to indicate a matching element has been found, and
* `false` otherwise.
* @returns The index of the last (highest-index) element in the array that
* passes the test. Otherwise -1 if no matching element is found.
* @signature
* R.findLastIndex(data, predicate)
* @example
* R.findLastIndex([1, 3, 4, 6], n => n % 2 === 1) // => 1
* @dataFirst
* @category Array
*/
declare function findLastIndex<T>(data: ReadonlyArray<T>, predicate: (value: T, index: number, data: ReadonlyArray<T>) => boolean): number;
/**
* Iterates the array in reverse order and returns the index of the first
* element that satisfies the provided testing function. If no elements satisfy
* the testing function, -1 is returned.
*
* See also `findLast` which returns the value of last element that satisfies
* the testing function (rather than its index).
*
* @param predicate - A function to execute for each element in the array. It
* should return `true` to indicate a matching element has been found, and
* `false` otherwise.
* @returns The index of the last (highest-index) element in the array that
* passes the test. Otherwise -1 if no matching element is found.
* @signature
* R.findLastIndex(fn)(items)
* @example
* R.pipe(
* [1, 3, 4, 6],
* R.findLastIndex(n => n % 2 === 1)
* ) // => 1
* @dataLast
* @category Array
*/
declare function findLastIndex<T>(predicate: (value: T, index: number, data: ReadonlyArray<T>) => boolean): (array: ReadonlyArray<T>) => number;
//#endregion
export { findLastIndex };
//# sourceMappingURL=findLastIndex-DhiR0gzK.d.ts.map