countBy
Groups the values of a Set by a derived key and counts how many fall into each group.
Available since v3.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
set | ReadonlySet<T> | The Set to summarize |
fn | function | Function deriving the grouping key from each value |
Returns
Section titled “Returns”Map<R, number> — A Map from derived key to the number of values in that group
Examples
Section titled “Examples”Count values by parity
Section titled “Count values by parity”Groups values by a derived key and counts how many fall into each group.
