MCPcopy Create free account
hub / github.com/clientdb/clientdb / getOrCreate

Function getOrCreate

core/utils/deepMap.ts:94–106  ·  view source on GitHub ↗
(path: unknown[], factory: () => V)

Source from the content-addressed store, hash-verified

92 }
93
94 function getOrCreate(path: unknown[], factory: () => V) {
95 const targetMap = getFinalTargetMap(path);
96
97 if (targetMap.has(targetSymbol)) {
98 return targetMap.get(targetSymbol) as V;
99 }
100
101 const newResult = factory();
102
103 targetMap.set(targetSymbol, newResult);
104
105 return newResult;
106 }
107
108 return { getOrCreate, has, set, get };
109}

Callers

nothing calls this directly

Calls 1

getFinalTargetMapFunction · 0.85

Tested by

no test coverage detected