1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function keyBy(list, propertyOrCb) {
|
4 | const isCallback = typeof propertyOrCb === 'function';
|
5 | return list.reduce((memo, item) => {
|
6 | const key = isCallback ? propertyOrCb(item) : item[propertyOrCb];
|
7 | memo[key] = item;
|
8 | return memo;
|
9 | }, {});
|
10 | }
|
11 | exports.default = keyBy;
|