push rasad front on new repo
This commit is contained in:
8
src/utils/groupBy.js
Normal file
8
src/utils/groupBy.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export function groupBy(array, key) {
|
||||
return array.reduce((hash, obj) => {
|
||||
if (obj[key] === undefined) return hash;
|
||||
return Object.assign(hash, {
|
||||
[obj[key]]: (hash[obj[key]] || []).concat(obj),
|
||||
});
|
||||
}, {});
|
||||
}
|
||||
Reference in New Issue
Block a user