edgeport - v1.0.3
    Preparing search index...

    Function decodeRemainingLength

    • Decodes an MQTT remaining-length varint starting at offset.

      Reads up to four continuation-flagged bytes and reconstructs the base-128 value, returning both the value and how many bytes it consumed so the caller can advance its cursor. Rejects a varint longer than four bytes, which would exceed MAX_REMAINING_LENGTH.

      Parameters

      • bytes: Uint8Array

        The buffer to read from.

      • offset: number = 0

        Index of the first varint byte; defaults to 0.

      Returns RemainingLength

      The decoded value and its byte length.

      If the varint runs past the buffer or exceeds four bytes.

      1.0.0

      import { decodeRemainingLength } from 'edgeport/mqtt';

      decodeRemainingLength(new Uint8Array([0x80, 0x01])); // { value: 128, bytesUsed: 2 }