(arr: T[], key: (item: T) => K)
| 35 | * Constructs a Map for an array given a key provider |
| 36 | */ |
| 37 | export function arrayToMap<K, T>(arr: T[], key: (item: T) => K): Map<K, T> { |
| 38 | const m = new Map<K, T>(); |
| 39 | for (const item of arr) { |
| 40 | m.set(key(item), item); |
| 41 | } |
| 42 | return m; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Provides a function that can be used to map arrays to string maps |