import { AsyncReducer } from "https://deno.land/x/rimbu@1.0.5/common/internal.ts";
const { count } = AsyncReducer;
Returns an AsyncReducer
that remembers the amount of input items provided.
Examples
Example 1
Example 1
const stream = AsyncStream.from(Stream.range({ amount: 10 }))
console.log(await stream.reduce(AsyncReducer.count()))
// => 10
console.log(await stream.reduce(AsyncReducer.count(async v => v < 5)))
// => 5
type
{ (): AsyncReducer<never, number>; <T>(pred: (value: T, index: number) => MaybePromise<boolean>): AsyncReducer<T, number>; }