Skip to main content
Module

x/rambda/groupBy.js

Faster and smaller alternative to Ramda
Go to Latest
File
export function groupBy(groupFn, list){ if (arguments.length === 1) return _list => groupBy(groupFn, _list)
const result = {} for (let i = 0; i < list.length; i++){ const item = list[ i ] const key = groupFn(item)
if (!result[ key ]){ result[ key ] = [] }
result[ key ].push(item) }
return result}