import { AsyncReducer } from "https://deno.land/x/rimbu@1.1.0/stream/async/index.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>, options?: { negate?: boolean; }): AsyncReducer<T, T | undefined>; <T, O>(pred: (value: T, index: number) => MaybePromise<boolean>, options?: { negate?: boolean; otherwise: AsyncOptLazy<O>; }): AsyncReducer<T, T | O>; }