UNPKG

@arrows/array

Version:
18 lines (17 loc) 607 B
declare type TestFn<T> = (element: T, index: number, arr: T[]) => boolean; declare type _Find = <T>(testFn: TestFn<T>, arr: T[]) => T | undefined; declare type _Find2 = <T>(testFn: TestFn<T>) => (arr: T[]) => T | undefined; declare type Find = _Find & _Find2; /** * Functional wrapper for Array.prototype.find * * Retrieves the value of the first element in the array * where predicate is true, and undefined otherwise. * * @param testFn Test function * @param arr Initial array * @returns Item that matches predicate or undefined */ declare const find: Find; export { find }; export default find;