UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

11 lines (9 loc) 240 B
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; } export { keyBy };