source:
node_modules/es-toolkit/dist/array/keyBy.mjs@
a762898
| Last change on this file since a762898 was a762898, checked in by , 5 months ago | |
|---|---|
|
|
| File size: 257 bytes | |
| Rev | Line | |
|---|---|---|
| [a762898] | 1 | function keyBy(arr, getKeyFromItem) { |
| 2 | const result = {}; | |
| 3 | for (let i = 0; i < arr.length; i++) { | |
| 4 | const item = arr[i]; | |
| 5 | const key = getKeyFromItem(item, i, arr); | |
| 6 | result[key] = item; | |
| 7 | } | |
| 8 | return result; | |
| 9 | } | |
| 10 | ||
| 11 | export { keyBy }; |
Note:
See TracBrowser
for help on using the repository browser.
