MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / getDefault

Function getDefault

src/util/map.ts:9–18  ·  view source on GitHub ↗
(map: Map<K, V>, key: K, factory: () => V)

Source from the content-addressed store, hash-verified

7 * @returns The existing value, or the new one if constructed
8 */
9export function getDefault<K, V>(map: Map<K, V>, key: K, factory: () => V): V {
10 let currentValue = map.get(key);
11
12 if (currentValue == null) {
13 currentValue = factory();
14 map.set(key, currentValue);
15 }
16
17 return currentValue;
18}

Callers 2

Calls 2

getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected