es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
15 lines (11 loc) • 334 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
function keyBy(set, getKeyFromValue) {
const result = new Map();
for (const value of set) {
const newKey = getKeyFromValue(value, value, set);
result.set(newKey, value);
}
return result;
}
exports.keyBy = keyBy;