Skip to content

decodeVlq

decodeVlq(bytes): number

Defined in: packages/format-varint/src/vlq/decode-vlq.ts:19

Decodes a buffer holding exactly one base-128 VLQ.

The one-shot counterpart of readVlq, for a caller that already knows the extent of the value. Decoding a run of values from one buffer is readVlq’s job — it does not re-scan and does not allocate per value.

Uint8Array

A buffer holding one complete encoding and nothing else.

number

The decoded value, from 0 to Number.MAX_SAFE_INTEGER.

When the encoding is truncated.

When the encoding is overlong, out of range, or followed by unread bytes.