Skip to content

Welshman Docs / @welshman/lib / countBy

Function: countBy() ​

countBy<T, K>(f, xs): Map<K, number>

Defined in: packages/lib/src/Tools.ts:641

Counts array elements by key function

Type Parameters ​

T ​

T

K ​

K

Parameters ​

f ​

(x) => K

Function to generate group key

xs ​

T[]

Array to count entries

Returns ​

Map<K, number>

Map of counts