Skip to content

Instantly share code, notes, and snippets.

@Shazambom
Created July 28, 2022 21:27
Show Gist options
  • Save Shazambom/86f84b0db478d3a1b1a9992f298a1258 to your computer and use it in GitHub Desktop.
Save Shazambom/86f84b0db478d3a1b1a9992f298a1258 to your computer and use it in GitHub Desktop.
Decode a byte string in base64 and inflate it using zip
import pako from "pako";
decode = async (base64) => {
let bin = window.atob(base64)
let bytes = new Uint8Array(bin.length)
for (let i = 0; i < bin.length; i++) {
bytes[i] = bin.charCodeAt(i);
}
let data = String.fromCharCode.apply(null, new Uint16Array(pako.inflate(bytes)));
return JSON.parse(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment