Files
2025-11-28 19:45:44 -07:00

16 lines
351 B
JavaScript

'use strict';
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
function countBy(arr, mapper) {
const result = {};
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
const key = mapper(item);
result[key] = (result[key] ?? 0) + 1;
}
return result;
}
exports.countBy = countBy;