zlib
zlib is a data format that wraps a DEFLATE stream with a 2 byte header and an Adler-32 checksum.
Produces and consumes zlib streams compatible with zlib's compress / uncompress.
Classes & types
class
zlib.Compressor
The zlib stream compressor object.
class
zlib.Decompressor
The zlib stream decompressor object.
Functions
zlib.compress | Compresses a string into a zlib stream. |
zlib.decompress | Decompresses a zlib stream. |
#zlib.compress
function zlib.compress(raw_data: string, options?: deflate.Options): string
Compresses a string into a zlib stream.
Parameters
| Name | Type | Description |
|---|---|---|
raw_data | string | The string to compress. |
optionsoptional | deflate.Options | The compression options. |
Returns
| Type | Name | Description |
|---|---|---|
string | compressed_data | The compressed string. |
#zlib.decompress
function zlib.decompress(compressed_data: string, dictionary?: string): string, integer
Decompresses a zlib stream.
Throws an error on malformed or truncated data, or if the checksum does not match; call via pcall() when processing untrusted input.
Parameters
| Name | Type | Description |
|---|---|---|
compressed_data | string | The zlib stream to decompress. |
dictionaryoptional | string | The preset dictionary, required if the data was compressed with one. |
Returns
| Type | Name | Description |
|---|---|---|
string | decompressed_data | The decompressed string. |
integer | end_position | The position of the first byte after the stream. |