| 345 | * @function |
| 346 | */ |
| 347 | export 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. |