import { gzip , ungzip } from "pako" ; import { base64ToBytes , bytesToBase64 } from "../../tools/encoding" ; param text returns async function compress ( text ) { return Promise . resolve ( ) . then ( ( ) => { const output = gzip ( text , { level : 9 } ) ; return bytesToBase64 ( output ) ; } ) ; } param text returns async function decompress ( text ) { return Promise . resolve ( ) . then ( ( ) => { return ungzip ( base64ToBytes ( text ) , { to : "string" } ) ; } ) ; } export function getCompressionResources ( ) { return { "compression/v2/compressText" : compress , "compression/v2/decompressText" : decompress } ; }