{"id":15447802,"url":"https://github.com/hazae41/naberius","last_synced_at":"2026-04-16T04:03:52.650Z","repository":{"id":65654086,"uuid":"596329731","full_name":"hazae41/naberius","owner":"hazae41","description":"WebAssembly bits processing utilities 🏎️ (unpack, pack, xor)","archived":false,"fork":false,"pushed_at":"2023-10-12T13:16:39.000Z","size":411,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-04T11:37:51.420Z","etag":null,"topics":["algorithms","bits","browser","deno","fast","pack","reproducible","rust","typescript","uint8array","unpack","webassembly","xor"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hazae41.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-02T00:10:51.000Z","updated_at":"2023-03-07T03:21:22.000Z","dependencies_parsed_at":"2024-10-01T20:20:27.359Z","dependency_job_id":null,"html_url":"https://github.com/hazae41/naberius","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.15000000000000002","last_synced_commit":"54e96c8847bda62879ce1c56385cffb6b5a8cf83"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/hazae41/naberius","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fnaberius","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fnaberius/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fnaberius/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fnaberius/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hazae41","download_url":"https://codeload.github.com/hazae41/naberius/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fnaberius/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31870517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","bits","browser","deno","fast","pack","reproducible","rust","typescript","uint8array","unpack","webassembly","xor"],"created_at":"2024-10-01T20:20:24.730Z","updated_at":"2026-04-16T04:03:52.625Z","avatar_url":"https://github.com/hazae41.png","language":"TypeScript","readme":"\u003cdiv\u003e\n  \u003cimg align=\"right\" width=\"128\" src=\"https://user-images.githubusercontent.com/4405263/216392312-16db6e26-5d1b-4c2d-899e-08b4093f64d3.png\"/\u003e\n  \u003cp\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n# Naberius\n\nWebAssembly bits processing utilities\n\n```\nnpm i @hazae41/naberius\n```\n\n[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/naberius) • [**Deno Module 🦖**](https://deno.land/x/naberius)\n\n## Algorithms\n- unpack: transform an array of bytes to an array of bits (aka bitfield)\n- pack_left: transform an array of bits to a left-padded array of bytes\n- pack_right: transform an array of bits to a right-padded array of bytes\n- xor_mod: apply in-place XOR to an array of bytes using a mask\n\n## Features\n- Reproducible building\n- Pre-bundled and streamed\n- Zero-copy memory slices\n\n## Benchmarks\n\n### unpack\n\n#### Deno\n\n```\ncpu: Apple M1 Max\nruntime: deno 1.30.0 (aarch64-apple-darwin)\n\nfile:///src/deno/bench/unpack.bench.ts\nbenchmark        time (avg)             (min … max)       p75       p99      p995\n--------------------------------------------------- -----------------------------\nwasm           3.31 µs/iter     (3.25 µs … 3.52 µs)   3.33 µs   3.52 µs   3.52 µs\njs (array)    10.44 µs/iter   (8.25 µs … 121.83 µs)  13.04 µs  14.25 µs  15.04 µs\njs (string)   51.27 µs/iter  (49.75 µs … 178.83 µs)  50.08 µs 109.71 µs 114.38 µs\n\nsummary\n  wasm\n   3.15x faster than js (array)\n   15.49x faster than js (string)\n```\n\n#### Node\n\n```\nsrc/node/bench/unpack.bench.ts\ncpu: Apple M1 Max\nruntime: node v18.12.1 (arm64-darwin)\n\n┌─────────────┬─────────────────┬────────────┬─────────────┐\n│   (index)   │     average     │  minimum   │   maximum   │\n├─────────────┼─────────────────┼────────────┼─────────────┤\n│    wasm     │ '3.09 μs/iter'  │ '2.04 μs'  │ '169.21 μs' │\n│ js (array)  │ '17.64 μs/iter' │ '16.71 μs' │ '854.29 μs' │\n│ js (string) │ '41.94 μs/iter' │ '40.04 μs' │ '218.75 μs' │\n└─────────────┴─────────────────┴────────────┴─────────────┘\n\nSummary\n- wasm is 5.71x faster than js (array)\n- wasm is 13.58x faster than js (string)\n```\n\n### pack_right\n\n#### Deno \n\n```\ncpu: Apple M1 Max\nruntime: deno 1.30.0 (aarch64-apple-darwin)\n\nfile:///src/deno/bench/pack_right.bench.ts\nbenchmark        time (avg)             (min … max)       p75       p99      p995\n--------------------------------------------------- -----------------------------\nwasm           2.75 µs/iter      (2.73 µs … 2.9 µs)   2.76 µs    2.9 µs    2.9 µs\njs (array)   668.34 µs/iter   (241.29 µs … 1.21 ms)   1.02 ms   1.11 ms   1.16 ms\njs (string)   43.83 µs/iter  (42.58 µs … 137.96 µs)  43.04 µs  78.25 µs  80.33 µs\n\nsummary\n  wasm\n   15.92x faster than js (string)\n   242.72x faster than js (array)\n```\n\n#### Node\n\n```\nsrc/node/bench/pack_right.bench.ts\ncpu: Apple M1 Max\nruntime: node v18.12.1 (arm64-darwin)\n\n┌─────────────┬──────────────────┬─────────────┬─────────────┐\n│   (index)   │     average      │   minimum   │   maximum   │\n├─────────────┼──────────────────┼─────────────┼─────────────┤\n│    wasm     │  '2.44 μs/iter'  │  '2.04 μs'  │ '111.17 μs' │\n│ js (array)  │ '118.16 μs/iter' │ '110.13 μs' │ '464.25 μs' │\n│ js (string) │ '42.15 μs/iter'  │ '40.62 μs'  │  '1.14 ms'  │\n└─────────────┴──────────────────┴─────────────┴─────────────┘\n\nSummary\n- wasm is 48.40x faster than js (array)\n- wasm is 17.26x faster than js (string)\n```\n\n### xor_mod\n\n#### Deno\n\n```\ncpu: Apple M1 Max\nruntime: deno 1.30.0 (aarch64-apple-darwin)\n\nfile:///src/deno/bench/xor_mod.bench.ts\nbenchmark      time (avg)             (min … max)       p75       p99      p995\n------------------------------------------------- -----------------------------\nwasm       888.48 ns/iter    (874.06 ns … 1.1 µs) 885.63 ns    1.1 µs    1.1 µs\njs           1.16 µs/iter     (1.15 µs … 1.17 µs)   1.16 µs   1.17 µs   1.17 µs\n\nsummary\n  wasm\n   1.3x faster than js\n```\n\n#### Node \n\n```\nsrc/node/bench/xor_mod.bench.ts\ncpu: Apple M1 Max\nruntime: node v18.12.1 (arm64-darwin)\n\n┌─────────┬──────────────────┬─────────────┬─────────────┐\n│ (index) │     average      │   minimum   │   maximum   │\n├─────────┼──────────────────┼─────────────┼─────────────┤\n│  wasm   │ '880.48 ns/iter' │ '750.00 ns' │ '154.00 μs' │\n│   js    │ '17.71 μs/iter'  │ '17.42 μs'  │ '610.67 μs' │\n└─────────┴──────────────────┴─────────────┴─────────────┘\n\nSummary\n- wasm is 20.11x faster than js\n```\n\n## Usage\n\n### Concatening bits\n\n```ts\nimport { Naberius, unpack, pack_right } from \"@hazae41/naberius\";\n\n// Wait for WASM to load\nNaberius.initSyncBundledOnce()\n\n// Create a header of bits\nconst headerBits = new Uint8Array([0x00, 0x01, 0x00, 0x01])\n\n// Create a body of bytes\nconst bodyBytes = new Uint8Array(256)\ncrypto.getRandomValues(bodyBytes)\n\n// Unpack it\nconst bodyBitsSlice = unpack(bodyBytes)\n\n// Concat both bits arrays\nconst fullBits = new Uint8Array(headerBits.length + bodyBitsSlice.bytes.length)\nfullBits.set(headerBits, 0)\nfullBits.set(bodyBitsSlice.bytes, headerBits.length)\n\nbodyBitsSlice.free()\n\n// Pack adding 0-padding to the right\nconst fullBytes = pack_right(fullBits).copyAndDispose()\n```\n\n### Xoring with mask\n\n```tsx\nconst bytes = new Uint8Array(1024)\ncrypto.getRandomValues(bytes)\n\nconst mask = new Uint8Array(4)\ncrypto.getRandomValues(mask)\n\nconst xored = xor_mod(bytes, mask).copyAndDispose()\nconst unxored = xor_mod(xored, mask).copyAndDispose()\n```\n\n## Building\n\n### Unreproducible building\n\nYou need to install [Rust](https://www.rust-lang.org/tools/install)\n\nThen, install [wasm-pack](https://github.com/rustwasm/wasm-pack)\n\n```bash\ncargo install wasm-pack\n```\n\nFinally, do a clean install and build\n\n```bash\nnpm ci \u0026\u0026 npm run build\n```\n\n### Reproducible building\n\nYou can build the exact same bytecode using Docker, just be sure you're on a `linux/amd64` host\n\n```bash\ndocker compose up --build\n```\n\nThen check that all the files are the same using `git status`\n\n```bash\ngit status --porcelain\n```\n\nIf the output is empty then the bytecode is the same as the one I commited\n\n### Automated checks\n\nEach time I commit to the repository, the GitHub's CI does the following:\n- Clone the repository\n- Reproduce the build using `docker compose up --build`\n- Throw an error if the `git status --porcelain` output is not empty\n\nEach time I release a new version tag on GitHub, the GitHub's CI does the following:\n- Clone the repository\n- Do not reproduce the build, as it's already checked by the task above\n- Throw an error if there is a `npm diff` between the cloned repository and the same version tag on NPM\n\nIf a version is present on NPM but not on GitHub, do not use!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazae41%2Fnaberius","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhazae41%2Fnaberius","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazae41%2Fnaberius/lists"}