Skip to content

@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

Independent and unofficial. Not affiliated with, endorsed by, or sponsored by Anker Innovations, Anker eufy, or eufy. "Anker eufy", "eufy" and "Anker" are trademarks of their respective owners. Use responsibly — rapid or failed logins can trigger captcha or temporary cooldowns.