UNPKG

@rxap/utilities

Version:

A collection of utility functions, types and interfaces.

15 lines 497 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GroupBy = GroupBy; function GroupBy(list, propertyKeyOrFunction) { const map = new Map(); for (const item of list) { const key = typeof propertyKeyOrFunction === 'function' ? propertyKeyOrFunction(item) : item[propertyKeyOrFunction]; if (!map.has(key)) { map.set(key, []); } map.get(key).push(item); } return map; } //# sourceMappingURL=group-by.js.map