MCPcopy
hub / github.com/yjs/yjs / writeStructsFromIdSet

Function writeStructsFromIdSet

src/utils/encoding.js:150–160  ·  view source on GitHub ↗
(encoder, store, idset)

Source from the content-addressed store, hash-verified

148 * @function
149 */
150export const writeStructsFromIdSet = (encoder, store, idset) => {
151 // write # states that were updated
152 encoding.writeVarUint(encoder.restEncoder, idset.clients.size)
153 // Write items with higher client ids first
154 // This heavily improves the conflict algorithm.
155 array.from(idset.clients.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, ids]) => {
156 const idRanges = ids.getIds()
157 const structs = /** @type {Array<GC|Item>} */ (store.clients.get(client))
158 writeStructs(encoder, structs, client, idRanges)
159 })
160}
161
162/**
163 * Resume computing structs generated by struct readers.

Callers 3

acceptChangesMethod · 0.90
rejectChangesMethod · 0.90

Calls 5

writeStructsFunction · 0.85
fromMethod · 0.80
forEachMethod · 0.45
getIdsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…