@qualithm/mqtt-wire - v0.1.5
    Preparing search index...

    Function variableByteIntegerLength

    • Calculates the number of bytes needed to encode a variable byte integer.

      Parameters

      • value: number

        The integer value to encode (0 to 268,435,455)

      Returns number

      Number of bytes needed (1-4)

      RangeError if value is out of range

      variableByteIntegerLength(0)       // 1
      variableByteIntegerLength(127) // 1
      variableByteIntegerLength(128) // 2
      variableByteIntegerLength(16383) // 2
      variableByteIntegerLength(16384) // 3