cloudhub-components
Version:
Various components to use in react projects
15 lines (13 loc) • 436 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = objFromArray;
// ----------------------------------------------------------------------
function objFromArray(array) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
return array.reduce(function (accumulator, current) {
accumulator[current[key]] = current;
return accumulator;
}, {});
}