Function findLast

  • Remarks

    Returns undefined if no element satisfies condition.

    Example

    import * as A from "flurp/array";
    import * as N from "flurp/number";

    const lastPositiveIndex = A.findLast(N.isPositive);
    lastPositiveIndex([-3, -4, -1, 5, 8, -2]); // 8
    lastPositiveIndex([-3, -4, -1, -5, -8, -2]); // undefined

    Type Parameters

    • T

    Parameters

    • condition: ((x: T) => boolean)
        • (x: T): boolean
        • Parameters

          • x: T

          Returns boolean

    Returns ((arr: readonly T[]) => undefined | T)

      • (arr: readonly T[]): undefined | T
      • Parameters

        • arr: readonly T[]

        Returns undefined | T