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