docs: def compress(data,
               mode=DEFAULT_MODE,
               quality=lib.BROTLI_DEFAULT_QUALITY,
               lgwin=lib.BROTLI_DEFAULT_WINDOW,
               lgblock=0,
               dictionary=b''):
      """
      Compress a string using Brotli.
  
      .. versionchanged:: 0.5.0
         Added ``mode``, ``quality``, `lgwin``, ``lgblock``, and ``dictionary``
         parameters.
  
      :param data: A bytestring containing the data to compress.
      :type data: ``bytes``
  
      :param mode: The encoder mode.
      :type mode: :class:`BrotliEncoderMode` or ``int``
  
      :param quality: Controls the compression-speed vs compression-density
          tradeoffs. The higher the quality, the slower the compression. The
          range of this value is 0 to 11.
      :type quality: ``int``
  
      :param lgwin: The base-2 logarithm of the sliding window size. The range of
          this value is 10 to 24.
      :type lgwin: ``int``
  
      :param lgblock: The base-2 logarithm of the maximum input block size. The
          range of this value is 16 to 24. If set to 0, the value will be set
          based on ``quality``.
      :type lgblock: ``int``
  
      :param dictionary: A pre-set dictionary for LZ77. Please use this with
          caution: if a dictionary is used for compression, the same dictionary
          **must** be used for decompression!
      :type dictionary: ``bytes``
  
      :returns: The compressed bytestring.
      :rtype: ``bytes``
      """
      # This method uses private variables on the Compressor object, and
      # generally does a whole lot of stuff that's not supported by the public
      # API. The goal here is to minimise the number of allocations and copies
      # we have to do. Users should prefer this method over the Compressor if
      # they know they have single-shot data.
      compressor = Compressor(
          mode=mode,
          quality=quality,
          lgwin=lgwin,
          lgblock=lgblock,
          dictionary=dictionary
      )
      compressed_data = compressor._compress(data, lib.BROTLI_OPERATION_FINISH)
      assert lib.BrotliEncoderIsFinished(compressor._encoder) == lib.BROTLI_TRUE
      assert (
          lib.BrotliEncoderHasMoreOutput(compressor._encoder) == lib.BROTLI_FALSE
      )
      return compressed_data