Package: effect
Module: Iterable
Computes how many elements of the iterable pass the given predicate.
Example (Counting matching elements)
import { Iterable } from "effect"
const result = Iterable.countBy([1, 2, 3, 4, 5], (n) => n % 2 === 0)
console.log(result) // 2
Signature
declare const countBy: { <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => number; <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): number; }
Since v3.16.0