MCPcopy Create free account
hub / github.com/Snapchat/Valdi / arrayToMap

Function arrayToMap

src/valdi_modules/src/valdi/foundation/src/map.ts:37–43  ·  view source on GitHub ↗
(arr: T[], key: (item: T) => K)

Source from the content-addressed store, hash-verified

35 * Constructs a Map for an array given a key provider
36 */
37export 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

Callers 1

arrayToMapFnFunction · 0.85

Calls 1

setMethod · 0.65

Tested by

no test coverage detected