Function find

  • Returns the value of the first item in the iterable or asynchronous iterable where predicate is true, undefined otherwise.

    Example

    const findEven = find((number: number) => number % 2 === 0);
    findEven([1, 2, 3, 4]); // 2
    findEven([1, 3, 5, 7]); // undefined

    Returns

    Curried function with predicate set in context.

    Type Parameters

    • Item

    Parameters

    • predicate: Unary<Item, boolean>

      Predicate function to search for item.

    Returns (<Iterable>(iterable: Iterable) => ReducerOutput<Iterable, Maybe<Item>>)

      • <Iterable>(iterable: Iterable): ReducerOutput<Iterable, Maybe<Item>>
      • Type Parameters

        • Iterable extends AsynchronousIterable<Item>

        Parameters

        • iterable: Iterable

        Returns ReducerOutput<Iterable, Maybe<Item>>