MCPcopy
hub / github.com/yjs/yjs / markPosition

Function markPosition

src/ytype.js:440–452  ·  view source on GitHub ↗
(searchMarker, p, index)

Source from the content-addressed store, hash-verified

438 * @param {number} index
439 */
440const markPosition = (searchMarker, p, index) => {
441 if (searchMarker.length >= maxSearchMarker) {
442 // override oldest marker (we don't want to create more objects)
443 const marker = searchMarker.reduce((a, b) => a.timestamp < b.timestamp ? a : b)
444 overwriteMarker(marker, p, index)
445 return marker
446 } else {
447 // create new marker
448 const pm = new ArraySearchMarker(p, index)
449 searchMarker.push(pm)
450 return pm
451 }
452}
453
454/**
455 * Search marker help us to find positions in the associative array faster.

Callers 1

findMarkerFunction · 0.85

Calls 2

overwriteMarkerFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…