UNPKG

374 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3function 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}
11exports.default = keyBy;