Compression options for Bun.deflateSync and Bun.gzipSync
interface
ZlibCompressionOptions
interface ZlibCompressionOptions
- level?: 0 | 1 | 5 | 3 | 4 | 6 | -1 | 2 | 7 | 8 | 9
The compression level to use. Must be between
-1and9.- A value of
-1uses the default compression level (Currently6) - A value of
0gives no compression - A value of
1gives least compression, fastest speed - A value of
9gives best compression, slowest speed
- A value of
- memLevel?: 1 | 5 | 3 | 4 | 6 | 2 | 7 | 8 | 9
How much memory should be allocated for the internal compression state.
A value of
1uses minimum memory but is slow and reduces compression ratio.A value of
9uses 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_FIXEDprevents the use of dynamic Huffman codes
Z_RLEis designed to be almost as fast asZ_HUFFMAN_ONLY, but give better compression for PNG image data.Z_FILTEREDforces more Huffman coding and less string matching, it is somewhat intermediate betweenZ_DEFAULT_STRATEGYandZ_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.