@monstermann/fn
Version:
A utility library for TypeScript.
25 lines (23 loc) • 513 B
JavaScript
import { dfdlT } from "@monstermann/dfdl";
//#region src/array/findLast.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
* ```
*/
const findLast = dfdlT((target, predicate) => {
return target.findLast(predicate);
}, 2);
//#endregion
export { findLast };