zlib module
Compress and decompress bytes with the zlib library. Two framings: gzip (the file format you see in .gz files and HTTP Content-Encoding: gzip) and raw deflate (used by WebSocket permessage-deflate and similar).
import "zlib" as zlib;
var compressed = zlib.gzip("Hello, World!");
var decompressed = zlib.gunzip(compressed);
print(decompressed); // Hello, World!
gzip framing
| Function | Description |
|---|---|
zlib.gzip(data) → string | gzip-framed, default compression level. |
zlib.gzip_at(data, level) → string | level: 0 (no compression) – 9 (best). |
zlib.gunzip(data) → string | Decompress gzip or zlib-framed input (auto-detect). |
Raw deflate
| Function | Description |
|---|---|
zlib.deflate(data) → string | Raw deflate, no header or checksum. |
zlib.deflate_at(data, level) → string | |
zlib.inflate(data) → string | Matches deflate. |
Misc
| Function | Description |
|---|---|
zlib.version() → string | zlib library version, e.g. "1.3.1". |