Public
Edited
Mar 26, 2024
1 fork
1 star
Insert cell
Insert cell
viewof input = Inputs.textarea({
placeholder: "Paste in a base64 value representing gzipped data",
rows: 10
})
Insert cell
html`<pre>${await decodeAndUnzip(input)}</pre>`
Insert cell
async function decodeAndUnzip(base64String) {
// Decode the Base64 string to a Uint8Array
const binaryString = atob(base64String);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}

// Unzip the bytes using the pako library
const unzipped = pako.inflate(bytes);

// Convert the unzipped bytes to a string
const decoder = new TextDecoder();
const result = decoder.decode(unzipped);

return result;
}
Insert cell
Insert cell
pako = import("https://unpkg.com/pako@2.1.0/dist/pako.esm.mjs?module")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more