ts-iterable-functions
    Preparing search index...

    Function _lastOrDefault

    • Returns the last element of the source iterable that satisfies the optional predicate, or undefined when none match.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • src: Iterable<T>

        Source iterable to enumerate.

      • pred: IndexedPredicate<T> = ...

        Predicate receiving each element and its index; the most recent truthy match is returned.

      Returns T | undefined

      The last matching element, or undefined when no match exists.

      Error Rethrows any error thrown by pred.

      const result = _lastOrDefault([1, 2, 3, 4], (value) => value > 4);
      console.log(result); // undefined

      or using the curried version:

      const result = pipeInto(
      [1, 2, 3, 4],
      lastOrDefault((value) => value % 2 === 0)
      );
      console.log(result); // 4