UNPKG

es-toolkit

Version:

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

12 lines (10 loc) 257 B
function keyBy(arr, getKeyFromItem) { const result = {}; for (let i = 0; i < arr.length; i++) { const item = arr[i]; const key = getKeyFromItem(item, i, arr); result[key] = item; } return result; } export { keyBy };