MCPcopy
hub / github.com/tinyplex/tinybase / getCreateFunction

Function getCreateFunction

src/common/definable.ts:230–246  ·  view source on GitHub ↗
(
  getFunction: (store: Store) => Thing,
  initFunction?: (thing: Thing) => void,
)

Source from the content-addressed store, hash-verified

228 ((): RowValue => defaultCellValue ?? (EMPTY_STRING as any as RowValue)));
229
230export const getCreateFunction = <
231 Thing extends
232 Metrics | Middleware | Indexes | Relationships | Checkpoints | Queries,
233>(
234 getFunction: (store: Store) => Thing,
235 initFunction?: (thing: Thing) => void,
236): ((store: Store) => Thing) => {
237 const thingsByStore: WeakMap<Store, Thing> = new WeakMap();
238 return (store: Store): Thing => {
239 if (!thingsByStore.has(store)) {
240 thingsByStore.set(store, getFunction(store));
241 }
242 const thing = thingsByStore.get(store) as Thing;
243 initFunction?.(thing);
244 return thing;
245 };
246};

Callers 6

index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90

Calls 1

getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…