import zlib from "zlib" ; param text returns async function compress ( text ) { const buff = Buffer . from ( text , "utf8" ) ; const compressed = await new Promise ( ( resolve , reject ) => { zlib . gzip ( buff , ( err , res ) => { if ( err ) return reject ( err ) ; resolve ( res ) ; } ) ; } ) ; return compressed . toString ( "base64" ) ; } param text returns async function decompress ( text ) { const compressedData = Buffer . from ( text , "base64" ) ; const decompressedData = await new Promise ( ( resolve , reject ) => { zlib . gunzip ( compressedData , ( err , res ) => { if ( err ) return reject ( err ) ; resolve ( res ) ; } ) ; } ) ; return decompressedData . toString ( "utf8" ) ; } export function getCompressionResources ( ) { return { "compression/v2/compressText" : compress , "compression/v2/decompressText" : decompress } ; }