Compression options for Bun.deflateSync
and Bun.gzipSync
Symbol
ZlibCompressionOptions
interface ZlibCompressionOptions
- level?: 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -1
The compression level to use. Must be between
-1
and9
.- A value of
-1
uses the default compression level (Currently6
) - A value of
0
gives no compression - A value of
1
gives least compression, fastest speed - A value of
9
gives best compression, slowest speed
- A value of
- memLevel?: 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9
How much memory should be allocated for the internal compression state.
A value of
1
uses minimum memory but is slow and reduces compression ratio.A value of
9
uses maximum memory for optimal speed. The default is8
. - strategy?: number
Tunes the compression algorithm.
Z_DEFAULT_STRATEGY
: For normal data (Default)Z_FILTERED
: For data produced by a filter or predictorZ_HUFFMAN_ONLY
: Force Huffman encoding only (no string match)Z_RLE
: Limit match distances to one (run-length encoding)Z_FIXED
prevents the use of dynamic Huffman codes
Z_RLE
is designed to be almost as fast asZ_HUFFMAN_ONLY
, but give better compression for PNG image data.Z_FILTERED
forces more Huffman coding and less string matching, it is somewhat intermediate betweenZ_DEFAULT_STRATEGY
andZ_HUFFMAN_ONLY
. Filtered data consists mostly of small values with a somewhat random distribution. - windowBits?: 25 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 28 | -9 | -10 | -11 | -12 | -13 | -14 | -15 | 26 | 27 | 29 | 30 | 31
The base 2 logarithm of the window size (the size of the history buffer).
Larger values of this parameter result in better compression at the expense of memory usage.
The following value ranges are supported:
9..15
: The output will have a zlib header and footer (Deflate)-9..-15
: The output will not have a zlib header or footer (Raw Deflate)25..31
(16+9..15
): The output will have a gzip header and footer (gzip)
The gzip header will have no file name, no extra data, no comment, no modification time (set to zero) and no header CRC.