Download tests/pack_bin.mjs from SharpMeow/unroll: direct link, hf CLI and curl.
- Browser
- Download file 871 Bytes
-
https://huggingface.co/spaces/SharpMeow/unroll/resolve/main/tests/pack_bin.mjs
- Command line
-
hf download hf://spaces/SharpMeow/unroll/tests/pack_bin.mjs
-
curl -L -o pack_bin.mjs https://huggingface.co/spaces/SharpMeow/unroll/resolve/main/tests/pack_bin.mjs
871 Bytes
| // Regression + benchmark: data/scroll.i16p.gz unpacks to exactly data/scroll.bin. | |
| // Run: node tests/pack_bin.mjs (needs the LFS files pulled) | |
| import { readFileSync } from 'node:fs'; | |
| import { createHash } from 'node:crypto'; | |
| import { unpackInt16 } from '../lib/formats.js'; | |
| const root = new URL('..', import.meta.url).pathname; | |
| const raw = readFileSync(root + 'data/scroll.bin'), packed = readFileSync(root + 'data/scroll.i16p.gz'); | |
| const h = (b) => createHash('sha256').update(Buffer.from(b)).digest('hex'); | |
| const t = performance.now(); | |
| const out = await unpackInt16(packed); | |
| const ms = performance.now() - t; | |
| if (h(out) !== h(raw)) { console.error('FAIL: unpacked bytes differ from scroll.bin'); process.exit(1); } | |
| console.log(`ok ${raw.length} B plain, ${packed.length} B packed (${(100 * packed.length / raw.length).toFixed(1)} %), unpack ${ms.toFixed(1)} ms`); | |