deno.land / x / rambda@v9.1.1 / src / countBy.js
123456789101112131415161718export 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}
Version Info