ts-iterable-functions
    Preparing search index...

    Function lastConst

    • Returns the last element of the source iterable that satisfies the optional predicate.

      Curried version of _last.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • pred: IndexedPredicate<T> = ...

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

      Returns (src: Iterable) => T

      The last element matching pred.

      Error Thrown when no element satisfies pred.

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

      or using the curried version:

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