Published
Edited
Jun 29, 2021
Importers
14 stars
Insert cell
Insert cell
license = {
const bytes = new Uint8Array(await FileAttachment("LICENSE.gz").arrayBuffer());
return new TextDecoder().decode(gunzip(bytes));
}
Insert cell
Insert cell
function gunzip(bytes) {
if (bytes[0] !== 0x1f || bytes[1] !== 0x8b || bytes[2] !== 0x08) throw new Error('Not a gzip file.');
let pos = 10; // skip fixed gzip header
let n = bytes[3];
while (n) { // skip extra header fields
while (bytes[pos] !== 0) pos++;
pos++; n = n & (n - 1);
}
return inflate(bytes.subarray(pos));
}
Insert cell
function inflate(bytes) {
const srcStart = 2000;
const mem = new Uint8Array(inflateWasm.mem.buffer);
mem.set(bytes, srcStart);
const dstStart = srcStart + bytes.length;
const dstEnd = inflateWasm.inflate(srcStart, dstStart);
return mem.slice(dstStart, dstEnd);
}
Insert cell
inflateWasm = {
const wasm = FileAttachment("inflate.wasm");
return (await (WebAssembly.instantiateStreaming ?
WebAssembly.instantiateStreaming(fetch(await wasm.url())) :
WebAssembly.instantiate(await wasm.arrayBuffer()))).instance.exports;
}
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