Function: toCount()
toCount():
Reducer
<unknown
,number
>
Returns a Reducer that counts the number of values it receives.
Use when composing reducers. Prefer count, countAsync, and countConcur for direct use on iterables.
Returns
Reducer
<unknown
, number
>
Example
console.log(
pipe(
[`sloth`, `more sloth`, `sleep`, `some sloth`],
map(string => [string.length, string]),
reduce(toGrouped(toCount(), toMap())),
),
)
//=> Map(2) { 5 => 2, 10 => 2 }