UNPKG

@lou.codes/iterables

Version:
19 lines (18 loc) 682 B
import type { IsomorphicIterable, Maybe, Unary } from "@lou.codes/types"; /** * Returns the value of the first item in the iterable or asynchronous iterable * where predicate is `true`, `undefined` otherwise. * * @category Asynchronous Reducers * @example * ```typescript * const findEven = find((number: number) => number % 2 === 0); * findEven([1, 2, 3, 4]); // 2 * findEven([1, 3, 5, 7]); // undefined * ``` * @param predicate Predicate function to search for item. * @returns Curried function with `predicate` set in context. */ export declare const find: <Item>( predicate: Unary<Item, boolean>, ) => (iterable: IsomorphicIterable<Item>) => Promise<Maybe<Item>>;