countBy
Groups the entries of a Map 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 |
|---|---|---|
map | ReadonlyMap<K, V> | The Map to summarize |
fn | function | Function deriving the grouping key from (value, key) |
Returns
Section titled “Returns”Map<R, number> — A Map from derived key to the number of entries in that group
Examples
Section titled “Examples”Count entries by parity
Section titled “Count entries by parity”Groups values by a derived key and counts how many fall into each group.
