UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

25 lines (23 loc) 486 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/array/find.ts /** * `find(array, predicate)` * * Returns the first element in `array` that satisfies the provided `predicate` function, or `undefined` if no element is found. * * ```ts * find([1, 2, 3, 4], (x) => x > 2); // 3 * ``` * * ```ts * pipe( * [1, 2, 3, 4], * find((x) => x > 2), * ); // 3 * ``` */ const find = dfdlT((target, predicate) => { return target.find(predicate); }, 2); //#endregion export { find };