UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

28 lines (26 loc) 820 B
import { ArrayGuard, ArrayPredicate } from "./internals/types.js"; //#region src/array/findLast.d.ts /** * `findLast(array, predicate)` * * Returns the last element in `array` that satisfies the provided `predicate` function, or `undefined` if no element is found. * * ```ts * findLast([1, 2, 3, 4], (x) => x > 2); // 4 * ``` * * ```ts * pipe( * [1, 2, 3, 4], * findLast((x) => x > 2), * ); // 4 * ``` */ declare const findLast: { <T, U extends T>(predicate: ArrayGuard<T, U>): (target: readonly T[]) => U | undefined; <T>(predicate: ArrayPredicate<T>): (target: readonly T[]) => T | undefined; <T, U extends T>(target: readonly T[], predicate: ArrayGuard<T, U>): U | undefined; <T>(target: readonly T[], predicate: ArrayPredicate<T>): T | undefined; }; //#endregion export { findLast };