UNPKG

@e-group/utils

Version:

eGroup team utils that share across projects.

16 lines (13 loc) 376 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = groupBy; function groupBy(xs, key) { return xs.reduce((rv, x) => { const v = key instanceof Function ? key(x) : x[key]; // Not use copy for better performance // eslint-disable-next-line no-param-reassign (rv[v] = rv[v] || []).push(x); return rv; }, {}); }