Skip to main content
Module

x/rimbu/mod.ts>Reducer.count

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
variable Reducer.count
import { Reducer } from "https://deno.land/x/rimbu@0.13.1/mod.ts";
const { count } = Reducer;

Returns a Reducer that remembers the amount of input items provided.

Examples

Example 1

const stream = Stream.range({ amount: 10 })
console.log(stream.reduce(Reducer.count()))
// => 10
console.log(stream.reduce(Reducer.count(v => v < 5)))
// => 5

type

{ (): Reducer<never, number>; <T>(pred: (value: T, index: number) => boolean): Reducer<T, number>; }