Function: toSum()
toSum():
Reducer
<number
,number
>
Returns a Reducer that sums the numbers it receives.
Use when composing reducers. Prefer sum, sumAsync, and sumConcur for direct use on iterables.
Returns
Reducer
<number
, number
>
Example
console.log(
pipe(
[`sloth`, `more sloth`, `sleep`, `some sloth`],
map(string => [string.length, string.length]),
reduce(toGrouped(toSum(), toMap())),
),
)
//=> Map(2) { 5 => 10, 10 => 20 }