MCPcopy Index your code
hub / github.com/tinyplex/tinybase / objEnsure

Function objEnsure

src/common/obj.ts:96–105  ·  view source on GitHub ↗
(
  obj: IdObj<Value>,
  id: Id | number,
  getDefaultValue: () => Value,
)

Source from the content-addressed store, hash-verified

94};
95
96export const objEnsure = <Value>(
97 obj: IdObj<Value>,
98 id: Id | number,
99 getDefaultValue: () => Value,
100): Value => {
101 if (!objHas(obj, id as Id)) {
102 obj[id] = getDefaultValue();
103 }
104 return obj[id] as Value;
105};
106
107export const objValidate = (
108 obj: IdObj<any> | undefined,

Callers 12

mergeContentOrChangesFunction · 0.90
getMergeableRowHashesFunction · 0.90
getMergeableRowDiffFunction · 0.90
getMergeableCellHashesFunction · 0.90
getMergeableCellDiffFunction · 0.90
getChangesFromYDocFunction · 0.90
getPersistedFunction · 0.90
docObjMatchFunction · 0.90
index.tsFile · 0.90
loadStoreFromStorageFunction · 0.90
getPersistedFunction · 0.90
mergeTablesStampsFunction · 0.90

Calls 1

objHasFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…