countBy (Functional Programming) es-toolkit
Creates a function that counts values by a key. Use it with pipe.
Info
Usage
countBy calls mapper for each value in the piped array and returns an object whose keys are mapper results and whose values are counts.
Parameters
mapper(item: T) => Krequired
The function that returns the key used for counting.
Returns
A function that maps a readonly T[] to counts by key.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.