Type alias ZlibCompressionOptions

ZlibCompressionOptions: { level?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; memLevel?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; strategy?: number; windowBits?: -9 | -10 | -11 | -12 | -13 | -14 | -15 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 25 | 26 | 27 | 28 | 29 | 30 | 31 }

Compression options for Bun.deflateSync and Bun.gzipSync

Type declaration

  • Optional level?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

    The compression level to use. Must be between -1 and 9.

    • A value of -1 uses the default compression level (Currently 6)
    • 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
  • Optional memLevel?: 1 | 2 | 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 is 8.

  • Optional strategy?: number

    Tunes the compression algorithm.

    • Z_DEFAULT_STRATEGY: For normal data (Default)
    • Z_FILTERED: For data produced by a filter or predictor
    • Z_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 as Z_HUFFMAN_ONLY, but give better compression for PNG image data.

    Z_FILTERED forces more Huffman coding and less string matching, it is somewhat intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Filtered data consists mostly of small values with a somewhat random distribution.

  • Optional windowBits?: -9 | -10 | -11 | -12 | -13 | -14 | -15 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 25 | 26 | 27 | 28 | 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.

Generated using TypeDoc