Skip to content

@mega-yfue/eufy-sdk / encodeVarint

Function: encodeVarint()

ts
function encodeVarint(value): number[];

Encode an unsigned integer as a base-128 varint, low group first with the continuation bit set on every group but the last.

Takes a number and rejects anything that is not a non-negative safe integer, rather than silently truncating: JavaScript's bitwise operators are 32-bit, so a naive shift-based loop wraps above 2³¹ and would emit a plausible-looking frame for the wrong value. Division keeps the full safe-integer range available and the guard makes the boundary explicit instead of surprising.

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.