import * as zlib from 'zlib' ; const compressionOptions = { level : zlib . constants . Z_BEST_COMPRESSION , } ; export async function compress ( buffer ) { return new Promise < Buffer > ( ( resolve , reject ) => { zlib . deflateRaw ( buffer , compressionOptions , ( err , data ) => { if ( err ) reject ( err ) ; else resolve ( data ) ; } ) ; } ) ; } export async function decompress ( buffer ) { return new Promise < Buffer > ( ( resolve , reject ) => { zlib . inflateRaw ( buffer , compressionOptions , ( err , data ) => { if ( err ) reject ( err ) ; else resolve ( data ) ; } ) ; } ) ; }