(encoder, rpos)
| 193 | * @function |
| 194 | */ |
| 195 | export 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 |
no test coverage detected
searching dependent graphs…