Download lib/bench-worker.js from SharpMeow/unroll: direct link, hf CLI and curl.
- Browser
- Download file 901 Bytes
-
https://huggingface.co/spaces/SharpMeow/unroll/resolve/main/lib/bench-worker.js
- Command line
-
hf download hf://spaces/SharpMeow/unroll/lib/bench-worker.js
-
curl -L -o bench-worker.js https://huggingface.co/spaces/SharpMeow/unroll/resolve/main/lib/bench-worker.js
901 Bytes
| // SPDX-License-Identifier: Apache-2.0 | |
| // Copyright 2026 Chase Hendrick | |
| // Runs the Ink Bench alignment and scoring off the main thread, so the page stays responsive. | |
| import * as C from './bench-core.js'; | |
| self.onmessage = async ({ data }) => { | |
| const { id, op } = data; | |
| try { | |
| if (op === 'align') { | |
| const al = await C.align(data.tgt, data.P, { start: data.start || null, onProgress: (f) => self.postMessage({ id, progress: f }) }); | |
| self.postMessage({ id, result: al }); | |
| } else if (op === 'score') { | |
| const { val, m } = C.applyAlignment(data.ref, data.P, data.al); | |
| const alignNcc = C.rnd(C.ncc(data.tgt || data.ref, val, m, 1), 6); | |
| const blurBest = C.blurEstimate(data.ref, val, m); | |
| self.postMessage({ id, result: { val, m, alignNcc, blurBest } }, [val.buffer, m.buffer]); | |
| } | |
| } catch (e) { self.postMessage({ id, error: String(e.message || e) }); } | |
| }; | |