@szilanor/stream
    Preparing search index...

    Variable findLastOrDefaultConst

    findLastOrDefault: <T>(
        defaultValue: ValueOrFactory<T>,
        predicate?: PredicateFunction<T>,
    ) => CollectorFunction<T, undefined | T> = lastOrDefault

    Type declaration

      • <T>(
            defaultValue: ValueOrFactory<T>,
            predicate?: PredicateFunction<T>,
        ): CollectorFunction<T, undefined | T>
      • Returns the last element in the source that satisfies the predicate or a default value if no such element is found.

        Type Parameters

        • T

          Type of items in the source.

        Parameters

        • defaultValue: ValueOrFactory<T>

          Default value to return if no element is found.

        • predicate: PredicateFunction<T> = ...

          Predicate function to determine if an element should be returned.

        Returns CollectorFunction<T, undefined | T>

        Collector that returns the last element in the source that satisfies the predicate or a default value if no such element is found.

        const result = lastOrDefault<number>(0, (x) => x > 1)([1, 2, 3]);
        console.log(result); // 3