MCPcopy
hub / github.com/yjs/yjs / createRandomIdSet

Function createRandomIdSet

tests/testHelper.js:395–409  ·  view source on GitHub ↗
(gen, clients, clockRange)

Source from the content-addressed store, hash-verified

393 * @param {number} clockRange (max clock - exclusive - by each client)
394 */
395export const createRandomIdSet = (gen, clients, clockRange) => {
396 const maxOpLen = 5
397 const numOfOps = math.ceil((clients * clockRange) / maxOpLen)
398 const idset = createIdSet()
399 for (let i = 0; i < numOfOps; i++) {
400 const client = prng.uint32(gen, 0, clients - 1)
401 const clockStart = prng.uint32(gen, 0, clockRange)
402 const len = prng.uint32(gen, 0, clockRange - clockStart)
403 addToIdSet(idset, client, clockStart, len)
404 }
405 if (idset.clients.size === clients && clients > 1 && prng.bool(gen)) {
406 idset.clients.delete(prng.uint32(gen, 0, clients))
407 }
408 return idset
409}
410
411/**
412 * @template T

Callers 6

testRepeatRandomDiffingFunction · 0.90
testRepeatRandomDeletesFunction · 0.90
testRepeatRandomDiffing2Function · 0.90
testRepeatRandomDiffing2Function · 0.90

Calls 3

createIdSetFunction · 0.90
addToIdSetFunction · 0.90
deleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…