MCPcopy Create free account
hub / github.com/tailscale/tailcat / countProgress

Function countProgress

web/app.js:69–86  ·  view source on GitHub ↗
(stream, total, wireBytes)

Source from the content-addressed store, hash-verified

67// status line as bytes pass through: loaded/total drives the bar,
68// wireBytes is the transfer size shown to the user.
69function countProgress(stream, total, wireBytes) {
70 const ofMB = wireBytes > 0 ? ` of ${(wireBytes / (1 << 20)).toFixed(1)} MB` : "";
71 const bar = $("load-progress");
72 let loaded = 0;
73 return stream.pipeThrough(new TransformStream({
74 transform(chunk, controller) {
75 loaded += chunk.byteLength;
76 if (total > 0) {
77 bar.value = loaded / total;
78 const pct = Math.min(100, Math.floor(100 * loaded / total));
79 setStatus(`Loading WebAssembly… ${pct}%${ofMB}`);
80 } else {
81 setStatus(`Loading WebAssembly…`);
82 }
83 controller.enqueue(chunk);
84 },
85 }));
86}
87
88// fetchWasm fetches the wasm with load progress. Static hosts like
89// GitHub Pages can't do Content-Encoding negotiation (and don't

Callers 1

fetchWasmFunction · 0.85

Calls 1

$Function · 0.85

Tested by

no test coverage detected