11 lines
300 B
JavaScript
11 lines
300 B
JavaScript
|
/* eslint-disable import/prefer-default-export */
|
||
|
export const isEmptyObject = obj =>
|
||
|
Object.keys(obj).length === 0 && obj.constructor === Object;
|
||
|
|
||
|
export const arrayToHashById = array =>
|
||
|
array.reduce((map, obj) => {
|
||
|
const newMap = map;
|
||
|
newMap[obj.id] = obj;
|
||
|
return newMap;
|
||
|
}, {});
|