xero-hero
Version:
Heroic utilities to simplify and enable your progress with the [xero-node](https://www.npmjs.com/package/xero-node) SDK.
56 lines (55 loc) • 1.69 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils/map.ts
var map_exports = {};
__export(map_exports, {
groupBy: () => groupBy,
keyBy: () => keyBy
});
module.exports = __toCommonJS(map_exports);
var getKey = (item, property) => {
return typeof property === "function" ? property(item) : item[property];
};
var keyBy = (ar, property) => {
return (ar || []).reduce(
(accumulator, item) => {
const key = getKey(item, property);
accumulator[key] = item;
return accumulator;
},
{}
);
};
var groupBy = (ar, property) => {
return (ar || []).reduce(
(accumulator, item) => {
const key = getKey(item, property);
accumulator[key] = accumulator[key] || [];
accumulator[key].push(item);
return accumulator;
},
{}
);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
groupBy,
keyBy
});
//# sourceMappingURL=map.js.map