Parameters
- arr: T[]
- fn: ((item: T, index: number) => [key: K, value: V])
- (item, index): [key: K, value: V]
Returns [key: K, value: V]
Returns Map<K, V>
Example
const map = arrayToMap([5, 4, 3, 2, 1], (item, i) => [i, item]);
console.log(map); // Map(5) { 0 => 5, 1 => 4, 2 => 3, 3 => 2, 4 => 1 }
Maps the provided array into a map