{{newin|[[11.0]]|110|type=function|text=Deprecates [[love.math.compress]]}}
Compresses a string or data using a specific compression algorithm.
{{notice|This function, depending on the compression format and level, can be slow if called repeatedly, such as from [[love.update]] or [[love.draw]]. Some benchmarks are available [https://github.com/Cyan4973/lz4#user-content-benchmarks here].}}
== Function ==
=== Synopsis ===
<source lang="lua">
compressedData = love.data.compress( container, format, rawstring, level )
</source>
=== Arguments ===
{{param|ContainerType|container|What type to return the compressed data as.}}
{{param|CompressedDataFormat|format|The format to use when compressing the string.}}
{{param|string|rawstring|The raw (un-compressed) string to compress.}}
{{param|number|level (-1)|The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used.}}
=== Returns ===
{{param|value|compressedData|[[CompressedData]]/[[string]] which contains the compressed version of rawstring.}}
== Function ==
=== Synopsis ===
<source lang="lua">
compressedData = love.data.compress( container, format, data, level )
</source>
=== Arguments ===
{{param|ContainerType|container|What type to return the compressed data as.}}
{{param|CompressedDataFormat|format|The format to use when compressing the data.}}
{{param|Data|data|A Data object containing the raw (un-compressed) data to compress.}}
{{param|number|level (-1)|The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used.}}
=== Returns ===
{{param|value|compressedData|[[CompressedData]]/[[string]] which contains the compressed version of data.}}
== See Also ==
* [[parent::love.data]]
* [[love.data.decompress]]
* [[Constructs::CompressedData]]
[[Category:Functions]]
{{#set:Description=Compresses a string or data using a specific compression algorithm.}}
== Other Languages ==
{{i18n|love.data.compress}}