import zlib from 'zlib' ; import { Compression } from './Compression' ; import { CompressOptions , CompressionOptions } from '../interfaces' ; import { CompressionExtensions , CompressionNames } from '../enums' ; /**
 * Deflate compression
 */ export class DeflateCompression extends Compression < CompressionOptions > { readonly compressionName = CompressionNames . DEFLATE ; readonly ext = CompressionExtensions . DEFLATE ; /**
     * Creates an instance of DeflateCompression.
     */ constructor ( options ) { super ( options ) ; } /**
     * Returns deflate compression instance in closure.
     */ getCompression ( ) { return zlib . createDeflate ( this . compressionOptions ) ; } /**
     * Build deflate compression options object.
     */ protected selectCompression ( ) { const options = { } ; if ( this . options . deflateLevel !== undefined ) { options . level = this . options . deflateLevel ; } if ( this . options . deflateMemoryLevel !== undefined ) { options . memLevel = this . options . deflateMemoryLevel ; } if ( this . options . deflateStrategy !== undefined ) { options . strategy = this . options . deflateStrategy ; } this . compressionOptions = options ; } }