Compress and decompress a string using gzip
by dledle2
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ski Game with Floating Points Compressed</title>
</head>
<body>
<script>
async function decompress(enc) {
const raw = atob(enc);
const bytes = Uint8Array.from(raw, c => c.charCodeAt(0));
const blob = new Blob([bytes]);
const ds = blob.stream().pipeThrough(new DecompressionStream('gzip'));
const reader = ds.getReader();
const parts = [];
while (true) {
const { done, value } = await reader.read();
if (done) break;
parts.push(value);
}
return new Blob(parts).text();
}
document.addEventListener('DOMContentLoaded', async () => {
const html = await...