interface
ZlibCompressionOptions
interface ZlibCompressionOptions
Compression options for Bun.deflateSync and Bun.gzipSync
- level?: 0 | 2 | 1 | 5 | 3 | 4 | -1 | 6 | 7 | 8 | 9
The compression level to use. Must be between
-1and9.-1uses the default compression level (6)0gives no compression1gives least compression, fastest speed9gives best compression, slowest speed
- memLevel?: 2 | 1 | 5 | 3 | 4 | 6 | 7 | 8 | 9
How much memory to allocate 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 has a zlib header and footer (Deflate)-9..-15: The output does not have a zlib header or footer (Raw Deflate)25..31(16+9..15): The output has a gzip header and footer (gzip)
The gzip header has no file name, no extra data, no comment, no modification time (set to zero) and no header CRC.