Takes unsigned number num and converts it into a Varint encoded
Uint8Array, returning a tuple consisting of a Uint8Array slice of the
encoded Varint, and an offset where the Varint encoded bytes end within the
Uint8Array.
If buf is not given then a Uint8Array will be created.
offset defaults to 0.
If passed buf then that will be written into, starting at offset. The
resulting returned Uint8Array will be a slice of buf. The resulting
returned number is effectively offset + bytesWritten.
Parameters
num: number | bigint
The number to encode.
buf: Uint8Array = ...
The buffer to write into.
offset: number = 0
The offset to start writing at.
Returns [Uint8Array_, number]
A tuple of the encoded Varint Uint8Array and the new offset.
Takes unsigned number
numand converts it into a Varint encodedUint8Array, returning a tuple consisting of aUint8Arrayslice of the encoded Varint, and an offset where the Varint encoded bytes end within theUint8Array.If
bufis not given then a Uint8Array will be created.offsetdefaults to0.If passed
bufthen that will be written into, starting atoffset. The resulting returnedUint8Arraywill be a slice ofbuf. The resulting returned number is effectivelyoffset + bytesWritten.