docs: def num2varint(num):
      """
      Converts a number to a variable length Int. Used for array length header
  
      :param: {number} num - The number
      :return: {string} hexstring of the variable Int.
      """
      # if (typeof num !== 'number') throw new Error('VarInt must be numeric')
      # if (num < 0) throw new RangeError('VarInts are unsigned (> 0)')
      # if (!Number.isSafeInteger(num)) throw new RangeError('VarInt must be a safe integer')
      if num < 0xfd:
          return num2hexstring(num)
      elif num <= 0xffff:
          # uint16
          return 'fd' + num2hexstring(number=num, size=2, little_endian=True)
      elif num <= 0xffffffff:
          # uint32
          return 'fe' + num2hexstring(number=num, size=4, little_endian=True)
      else:
          # uint64
          return 'ff' + num2hexstring(number=num, size=8, little_endian=True)