dbmaster-cli
Version:
Tool for converting tables between Fifa Soccer Games
15 lines (14 loc) • 482 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortAggregateFn = exports.aggregateFn = void 0;
exports.aggregateFn = (agg, data, field) => {
const value = data[field];
const index = agg.findIndex((f) => f.value === value);
if (index === -1) {
agg.push({ value, count: 1 });
}
else {
agg[index] = { ...agg[index], count: agg[index].count + 1 };
}
};
exports.sortAggregateFn = (a, b) => b.count - a.count;