Zlib compression and decompression built on miniz. Provides raw deflate/inflate, zlib-wrapped compress/decompress, gzip/gunzip, and CRC-32/Adler-32 checksum functions.
| Name | Signature |
|---|---|
deflate | deflate(data, level) -> compressed, err |
compress | compress(data, level) -> compressed, err |
gzip | gzip(data, level) -> compressed, err |
inflate | inflate(data, max_size) -> decompressed, bytes_consumed, err |
decompress | decompress(data, max_size) -> decompressed, bytes_consumed, err |
gunzip | gunzip(data, max_size) -> decompressed, bytes_consumed, err |
crc32 | crc32(data, initial) -> checksum |
adler32 | adler32(data, initial) -> checksum |
deflate(
data,level) ->compressed,err
Compress data using raw deflate (no header/trailer)
Level ranges from 0 (no compression) to 10 (maximum), default 6.
compress(
data,level) ->compressed,err
Compress data with zlib wrapping (header + adler32 footer)
Level ranges from 0 (no compression) to 10 (maximum), default 6.
gzip(
data,level) ->compressed,err
Compress data in gzip format (RFC 1952)
Level ranges from 0 (no compression) to 10 (maximum), default 6.
Output is compatible with the gzip command-line tool.
inflate(
data,max_size) ->decompressed,bytes_consumed,err
Decompress raw deflate data
Returns the decompressed data and the number of compressed bytes
consumed from the input. max_size caps the output buffer to
guard against decompression bombs (default 64 MB).
decompress(
data,max_size) ->decompressed,bytes_consumed,err
Decompress zlib-wrapped data
Input must include the zlib header and adler32 footer. Returns the
decompressed data and the number of bytes consumed from the input.
max_size caps the output buffer (default 64 MB).
gunzip(
data,max_size) ->decompressed,bytes_consumed,err
Decompress gzip data (RFC 1952)
Parses the gzip header, inflates the payload, and validates the
CRC32 trailer. Compatible with output from the gzip command.
Returns the decompressed data and total bytes consumed.
max_size caps the output buffer (default 64 MB).
crc32(
data,initial) ->checksum
Compute CRC-32 checksum
Returns the CRC-32 value as a number. Pass a previous result as
initial to compute a running checksum over multiple chunks.
adler32(
data,initial) ->checksum
Compute Adler-32 checksum
Returns the Adler-32 value as a number. Pass a previous result as
initial to compute a running checksum over multiple chunks.