import { curryN } from "@unboxing/function"; import { ArrPred } from '@unboxing/core' interface Find { (fn: ArrPred, list: ArrayLike): T | undefined; (fn: ArrPred): (list: ArrayLike) => T | undefined; } // Returns the first element of the list which matches the predicate, or `undefined` if no element matches. export const findArray = curryN(2, (fn: ArrPred, arr: ArrayLike = []) => { for (let i = 0; i < arr.length; i++) { if (fn(arr[i], i, arr)) { return arr[i]; } } }) as Find