You can perform GZIP compression and decompression within a Restfox plugin or script by importing the pako library and utilizing the rf global object for buffer and base64 conversions.
To compress a string, convert it to an ArrayBuffer, use pako.deflate(), and then convert the resulting Uint8Array to a base64 string.
To decompress, convert a base64 string back to a Uint8Array, use pako.inflate(), and then convert the resulting buffer back to a string.
import pako from 'https://unpkg.com/pako@2.1.0/dist/pako.esm.mjs?module'
// compressing a string to a base64 gzipped string
const buffer = rf.arrayBuffer.fromString('My Gzipped Text')
const compressedBuffer = pako.deflate(buffer)
const compressedText = rf.base64.fromUint8Array(compressedBuffer)
console.log(compressedText) // output: eJzzrVQISa0oAQAJewKM
// decompressing a base64 gzipped string
const buffer2 = rf.base64.toUint8Array(compressedText)
const decompressedGzip = pako.inflate(buffer2)
const uncompressedText = rf.arrayBuffer.toString(decompressedGzip)
console.log(uncompressedText) // output: My Gzipped Text