MCPcopy Index your code
hub / github.com/yjs/yjs / writeRelativePosition

Function writeRelativePosition

src/utils/RelativePosition.js:195–213  ·  view source on GitHub ↗
(encoder, rpos)

Source from the content-addressed store, hash-verified

193 * @function
194 */
195export const writeRelativePosition = (encoder, rpos) => {
196 const { type, tname, item, assoc } = rpos
197 if (item !== null) {
198 encoding.writeVarUint(encoder, 0)
199 writeID(encoder, item)
200 } else if (tname !== null) {
201 // case 2: found position at the end of the list and type is stored in y.share
202 encoding.writeUint8(encoder, 1)
203 encoding.writeVarString(encoder, tname)
204 } else if (type !== null) {
205 // case 3: found position at the end of the list and type is attached to an item
206 encoding.writeUint8(encoder, 2)
207 writeID(encoder, type)
208 } else {
209 throw error.unexpectedCase()
210 }
211 encoding.writeVarInt(encoder, assoc)
212 return encoder
213}
214
215/**
216 * @param {RelativePosition} rpos

Callers 1

encodeRelativePositionFunction · 0.85

Calls 1

writeIDFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…