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

Function yMapMatch

test/unit/persisters/common/mocks.ts:62–89  ·  view source on GitHub ↗
(
  yMapOrParent: YMap<any>,
  idInParent: Id | undefined,
  obj: {[id: Id]: any},
  set: (yMap: YMap<any>, id: Id, rawContent: any) => 1 | void,
)

Source from the content-addressed store, hash-verified

60 );
61
62const yMapMatch = (
63 yMapOrParent: YMap<any>,
64 idInParent: Id | undefined,
65 obj: {[id: Id]: any},
66 set: (yMap: YMap<any>, id: Id, rawContent: any) => 1 | void,
67): 1 | void => {
68 const yMap =
69 idInParent == undefined
70 ? yMapOrParent
71 : (yMapOrParent.get(idInParent) ??
72 yMapOrParent.set(idInParent, new YMap()));
73 let changed: 1 | undefined;
74 Object.entries(obj).forEach(([id, value]) => {
75 if (set(yMap, id, value)) {
76 changed = 1;
77 }
78 });
79 yMap.forEach((_: any, id: Id) => {
80 if (obj[id] == null) {
81 yMap.delete(id);
82 changed = 1;
83 }
84 });
85 if (idInParent != undefined && !yMap.size) {
86 yMapOrParent.delete(idInParent);
87 }
88 return changed;
89};
90
91const objEnsure = <Value>(
92 obj: {[id: Id]: Value},

Callers 1

mocks.tsFile · 0.70

Calls 3

setFunction · 0.85
getMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…