LendAndRegret/node_modules/es-toolkit/dist/map/countBy.js
2026-05-02 17:27:43 +08:00

15 lines
360 B
JavaScript

'use strict';
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
function countBy(map, mapper) {
const result = new Map();
for (const [key, value] of map) {
const mappedKey = mapper(value, key, map);
result.set(mappedKey, (result.get(mappedKey) ?? 0) + 1);
}
return result;
}
exports.countBy = countBy;