code: def to_int(
      primitive: Primitives = None, hexstr: HexStr = None, text: str = None
  ) -> int:
      
      if hexstr is not None:
          return int(hexstr, 16)
      elif text is not None:
          return int(text)
      elif isinstance(primitive, (bytes, bytearray)):
          return big_endian_to_int(primitive)
      elif isinstance(primitive, str):
          raise TypeError("Pass in strings with keyword hexstr or text")
      elif isinstance(primitive, (int, bool)):
          return int(primitive)
      else:
          raise TypeError(
              "Invalid type.  Expected one of int/bool/str/bytes/bytearray.  Got "
              "{0}".format(type(primitive))
          )
docs: Converts value to its integer representation.
      Values are converted this way:
  
       * primitive:
  
         * bytes, bytearrays: big-endian integer
         * bool: True => 1, False => 0
       * hexstr: interpret hex as integer
       * text: interpret as string of digits, like '12' => 12