@mega-yfue/eufy-sdk / zigzag
Function: zigzag()
ts
function zigzag(value): number;ZigZag-encode a signed integer, mapping small negatives onto small unsigned values so a sint32 costs one byte rather than ten.
The clean line needs this for map coordinates, which are signed centimetres and routinely negative — a robot sent to a point encoded as a plain varint goes somewhere real and wrong. Kept separate from encodeVarint because the choice belongs to the field's declared type, which only the caller knows: int32 and sint32 are the same wire type and encode the same number differently.
Parameters
value
number
Returns
number