Given a non empty buf, starting at offset (default: 0), begin decoding bytes as
Varint encoded bytes, for a maximum of 10 bytes (offset + 10). The returned
tuple is of the decoded varint 32-bit number, and the new offset with which
to continue decoding other data.
If a bigint in return is undesired, the decode32 function will return a
number, but this should only be used in cases where the varint is
assured to be 32-bits. If in doubt, use decode().
To know how many bytes the Varint took to encode, simply negate offset
from the returned new offset.
Parameters
buf: Uint8Array
The buffer to decode from.
offset: number = 0
The offset to start decoding from.
Returns [bigint, number]
A tuple of the decoded varint 64-bit number, and the new offset.
Given a non empty
buf, starting atoffset(default: 0), begin decoding bytes as Varint encoded bytes, for a maximum of 10 bytes (offset + 10). The returned tuple is of the decoded varint 32-bit number, and the new offset with which to continue decoding other data.If a
bigintin return is undesired, thedecode32function will return anumber, but this should only be used in cases where the varint is assured to be 32-bits. If in doubt, usedecode().To know how many bytes the Varint took to encode, simply negate
offsetfrom the returned newoffset.