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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more