MCPcopy
hub / github.com/yjs/yjs / addStackToRestSS

Function addStackToRestSS

src/utils/encoding.js:247–266  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

245 // })
246
247 const addStackToRestSS = () => {
248 for (const item of stack) {
249 const client = item.id.client
250 const inapplicableItems = clientsStructRefs.clients.get(client)
251 if (inapplicableItems) {
252 // decrement because we weren't able to apply previous operation
253 inapplicableItems.i--
254 restStructs.clients.set(client, inapplicableItems.refs.slice(inapplicableItems.i))
255 clientsStructRefs.clients.delete(client)
256 inapplicableItems.i = 0
257 inapplicableItems.refs = []
258 } else {
259 // item was the last item on clientsStructRefs and the field was already cleared. Add item to restStructs and continue
260 restStructs.clients.set(client, [item])
261 }
262 // remove client from clientsStructRefsIds to prevent users from applying the same update again
263 clientsStructRefsIds = clientsStructRefsIds.filter(c => c !== client)
264 }
265 stack.length = 0
266 }
267
268 // iterate over all struct readers until we are done
269 while (true) {

Callers 1

integrateStructsFunction · 0.85

Calls 3

getMethod · 0.45
sliceMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…