UNPKG

@shopware/api-client

Version:
12 lines (9 loc) 361 B
import { gzipSync, strToU8 } from 'fflate'; function encodeForQuery(obj) { const json = JSON.stringify(obj); const compressed = gzipSync(strToU8(json)); let base64 = btoa(String.fromCharCode.apply(null, Array.from(compressed))); base64 = base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); return base64; } export { encodeForQuery };