encodeVlq
encodeVlq(
value):Uint8Array<ArrayBuffer>
Defined in: packages/format-varint/src/vlq/encode-vlq.ts:20
Encodes a non-negative integer as a base-128 VLQ, most significant group first, with the continuation bit set on every byte but the last.
Used by ASN.1 X.690 for tag numbers (§8.1.2.4) and OID arcs (§8.19.2), and by Standard MIDI Files for delta times. DWARF, WebAssembly and Protocol Buffers use the little-endian LEB128 member of the same family instead, which this is not interchangeable with.
Time complexity: O(log₁₂₈ value).
Parameters
Section titled “Parameters”number
A non-negative safe integer.
Returns
Section titled “Returns”Uint8Array<ArrayBuffer>
A fresh buffer holding the encoding, never empty.
Throws
Section titled “Throws”When value is negative, fractional, or beyond
Number.MAX_SAFE_INTEGER.