ts-iterable-functions
    Preparing search index...

    Function firstOrDefaultConst

    • Returns the first element in the source iterable that satisfies the predicate or undefined if none do.

      Curried version of _firstOrDefault.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • pred: IndexedPredicate<T> = ...

        Predicate receiving the current value and index; defaults to a function that accepts every value.

      Returns (src: Iterable) => T | undefined

      The first matching element, or undefined when the predicate never returns true.

      const value = _firstOrDefault([10, 20, 30]);
      console.log(value); // 10

      or using the curried version:

      const value = pipeInto(
      [1, 2, 3],
      firstOrDefault((n, i) => n > 5 || i > 5)
      );
      console.log(value); // undefined