import { AsyncReducer } from "https://deno.land/x/rimbu@1.0.5/common/async-reducer.ts";
const { lastWhere } = AsyncReducer;
Returns an AsyncReducer
that remembers the last input value for which the given pred
function returns true.
Examples
Example 1
Example 1
await AsyncStream.from(Stream.range({ amount: 10 })).reduce(AsyncReducer.lastWhere(async v => v > 5)))
// => 9
type
{ <T>(pred: (value: T, index: number) => MaybePromise<boolean>): AsyncReducer<T, T | undefined>; <T, O>(pred: (value: T, index: number) => MaybePromise<boolean>, otherwise: AsyncOptLazy<O>): AsyncReducer<T, T | O>; }