MCPcopy
hub / github.com/yjs/yjs / findIndexInIdRanges

Function findIndexInIdRanges

src/utils/IdSet.js:347–364  ·  view source on GitHub ↗
(dis, clock)

Source from the content-addressed store, hash-verified

345 * @function
346 */
347export const findIndexInIdRanges = (dis, clock) => {
348 let left = 0
349 let right = dis.length - 1
350 while (left <= right) {
351 const midindex = math.floor((left + right) / 2)
352 const mid = dis[midindex]
353 const midclock = mid.clock
354 if (midclock <= clock) {
355 if (clock < midclock + mid.len) {
356 return midindex
357 }
358 left = midindex + 1
359 } else {
360 right = midindex - 1
361 }
362 }
363 return null
364}
365
366/**
367 * Find the first range that contains clock or comes after clock.

Callers 2

hasMethod · 0.90
hasMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…