import { AsyncReducer } from "https://deno.land/x/rimbu@1.0.5/common/async-reducer.ts";
const { firstWhere } = AsyncReducer;
Returns an AsyncReducer
that remembers the first input value for which the given pred
function returns true.
Examples
Example 1
Example 1
await AsyncStream.from(Stream.range({ amount: 10 })).reduce(AsyncReducer.firstWhere(async v => v > 5)))
// => 6
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>; }