Skip to content

readQuicVarint

readQuicVarint(reader): number

Defined in: packages/format-varint/src/quic/read-quic-varint.ts:23

Reads one QUIC variable-length integer from reader, advancing it past the bytes consumed.

Accepts a longer encoding than needed (0x4025 is 37): QUIC allows it outside of frame types, and checking minimality is the protocol layer’s job where it applies.

Time complexity: O(1).

ByteReader

Cursor positioned at the first byte of the encoding.

number

The decoded value, from 0 to Number.MAX_SAFE_INTEGER.

When fewer bytes remain than the length prefix announces.

When the value is beyond Number.MAX_SAFE_INTEGER; QUIC allows up to 2^62 - 1, so such an encoding is well-formed.