dreamworkAPI
Ctrl K
GitHub
libraryDocs / zlib

zlib

librarysharedmenusource

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

Functions

zlib.compressCompresses a string into a zlib stream.
zlib.decompressDecompresses a zlib stream.

#zlib.compress

sharedmenunodiscardsource
function zlib.compress(raw_data: string, options?: deflate.Options): string

Compresses a string into a zlib stream.

Parameters
NameTypeDescription
raw_datastringThe string to compress.
optionsoptionaldeflate.OptionsThe compression options.
Returns
TypeNameDescription
stringcompressed_dataThe compressed string.

#zlib.decompress

sharedmenunodiscardsource
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
NameTypeDescription
compressed_datastringThe zlib stream to decompress.
dictionaryoptionalstringThe preset dictionary, required if the data was compressed with one.
Returns
TypeNameDescription
stringdecompressed_dataThe decompressed string.
integerend_positionThe position of the first byte after the stream.
Generated from the dreamwork meta branch.