(array: T[], keyOf: (item: T) => K)
| 12 | }; |
| 13 | |
| 14 | export const keyBy = <T, K>(array: T[], keyOf: (item: T) => K): Map<K, T> => { |
| 15 | return array.reduce((map, item) => { |
| 16 | const key = keyOf(item); |
| 17 | map.set(key, item); |
| 18 | return map; |
| 19 | }, new Map<K, T>()); |
| 20 | }; |
| 21 | |
| 22 | export const upsertArray = <T>(array: T[], item: T) => { |
| 23 | const index = array.indexOf(item); |
no test coverage detected