-
Notifications
You must be signed in to change notification settings - Fork 24
/
hw-base91.html
45 lines (39 loc) · 1.39 KB
/
hw-base91.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Zstandard WASM</title>
</head>
<body>
<div id="placeholder"></div>
<script type="module">
// Prefer local version (if available) ---
const Base91Local = await import("./dist/index.js").then(m => m.Base91).catch(() => undefined);
import { Base91 as Base91External } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.js";
const Base91 = Base91Local ?? Base91External;
const base91 = await Base91.load();
const data = new Uint8Array(Array.from({ length: 100 }, (_, i) => Math.random() * 100));
const encoded_data = await base91.encode(data);
const decoded_data = await base91.decode(encoded_data);
document.getElementById("placeholder").innerHTML = `\
<ul>
<li>Data Size (bytes): ${data.byteLength}</li>
<li>Endoded Size (bytes): ${encoded_data.length}</li>
<li>Decoded Size (bytes): ${decoded_data.byteLength}</li>
</ul>
<h4>Data: </h4>
<code>
${data}
</code>
<h4>Base 91: </h4>
<code id="base91">
</code>
<h4>Decoded: </h4>
<code>
${decoded_data}
</code>
`;
document.getElementById("base91").innerText = encoded_data;
</script>
</body>
</html>