UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

25 lines (23 loc) 633 B
import { ArrayPredicate } from "./internals/types.js"; //#region src/array/countBy.d.ts /** * `countBy(target, predicate)` * * Counts the number of elements in the `target` array satisfy the provided `predicate` function. * * ```ts * const isEven = (n) => n % 2 === 0; * countBy([1, 2, 3, 4, 5], isEven); // 2 * ``` * * ```ts * const isEven = (n) => n % 2 === 0; * pipe([1, 2, 3, 4, 5], countBy(isEven)); // 2 * ``` */ declare const countBy: { <T>(predicate: ArrayPredicate<T>): (target: readonly T[]) => number; <T>(target: readonly T[], predicate: ArrayPredicate<T>): number; }; //#endregion export { countBy };