deno.land / x / rambda@v9.1.1 / src / countBy.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export function countBy(fn, list){ if (arguments.length === 1){ return _list => countBy(fn, _list) } const willReturn = {}
list.forEach(item => { const key = fn(item) if (!willReturn[ key ]){ willReturn[ key ] = 1 } else { willReturn[ key ]++ } })
return willReturn}
rambda

Version Info

Tagged at
2 months ago