{"id":24810094,"url":"https://github.com/binhtran432k/varbyte-printable","last_synced_at":"2025-10-13T11:31:30.021Z","repository":{"id":274441366,"uuid":"922811377","full_name":"binhtran432k/varbyte-printable","owner":"binhtran432k","description":"A library for encoding variable-length bytes into a compact, printable, and JSON/JavaScript-safe string format.","archived":false,"fork":false,"pushed_at":"2025-01-30T06:50:14.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T20:16:40.864Z","etag":null,"topics":["binary-to-text","bun","compression","data-serialization","encoding","oxc","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/varbyte-printable","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/binhtran432k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-27T05:34:40.000Z","updated_at":"2025-01-30T06:48:24.000Z","dependencies_parsed_at":"2025-01-27T11:37:33.798Z","dependency_job_id":"79d71e4b-a935-4ef2-91e8-2eae6751f5a5","html_url":"https://github.com/binhtran432k/varbyte-printable","commit_stats":null,"previous_names":["binhtran432k/varbyte-printable"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/binhtran432k/varbyte-printable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binhtran432k%2Fvarbyte-printable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binhtran432k%2Fvarbyte-printable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binhtran432k%2Fvarbyte-printable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binhtran432k%2Fvarbyte-printable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binhtran432k","download_url":"https://codeload.github.com/binhtran432k/varbyte-printable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binhtran432k%2Fvarbyte-printable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014793,"owners_count":26085594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"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":["binary-to-text","bun","compression","data-serialization","encoding","oxc","typescript"],"created_at":"2025-01-30T11:17:06.092Z","updated_at":"2025-10-13T11:31:29.711Z","avatar_url":"https://github.com/binhtran432k.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# varbyte-printable\n\n[![NPM Version](https://img.shields.io/npm/v/varbyte-printable)](https://www.npmjs.com/package/varbyte-printable)\n[![NPM Bundle Size](https://img.shields.io/bundlephobia/minzip/varbyte-printable)](https://www.npmjs.com/package/varbyte-printable)\n[![CI Workflow](https://github.com/binhtran432k/varbyte-printable/actions/workflows/ci.yml/badge.svg)](https://github.com/binhtran432k/varbyte-printable/actions/workflows/ci.yml)\n[![CD Workflow](https://github.com/binhtran432k/varbyte-printable/actions/workflows/cd.yml/badge.svg)](https://github.com/binhtran432k/varbyte-printable/actions/workflows/cd.yml)\n\nA library for encoding variable-length bytes into a compact, printable, and\nJSON/JavaScript-safe string format.\n\n\u003c!--toc:start--\u003e\n\n- [About](#about)\n- [Features](#features)\n- [Installation](#installation)\n- [How It Works](#how-it-works)\n- [Usage](#usage)\n- [Development](#development)\n- [References](#references)\n\u003c!--toc:end--\u003e\n\n## About\n\n`varbyte-printable` is a lightweight library that encodes arrays of bytes into\na **compact, printable** format while ensuring compatibility with **JSON and\nJavaScript-safe strings**.\n\nThe encoding algorithm is inspired by **Lezer** by [Marijn\nHaverbeke](https://github.com/lezer-parser), borrowing key logic to achieve\nefficient compression.\n\nThis project is built using:\n\n- **Bun** for fast development and bundling.\n- **oxc-transform** for isolated TypeScript declaration generation.\n\n## Features\n\n- **Compact Encoding**: Reduces byte array size.\n- **Printable Output**: Ensures all characters are JSON-safe.\n- **JavaScript-Friendly**: Compatible with JavaScript strings.\n\n## Installation\n\nYou can install `varbyte-printable` using:\n\n```sh\nbun add varbyte-printable\n# or using npm\nnpm install varbyte-printable\n```\n\n## How It Works\n\nThe encoding algorithm converts numbers into groups of printable ASCII characters:\n\n- `0xFFFF`, often used as a placeholder, is encoded as `'~'`.\n- Characters from `' '` (32) to `'}'` (125), excluding `'\"'` (34) and `'\\\\'`\n  (92), represent values from **0 to 91**.\n- The **first bit** in each encoded character indicates whether it is the final\n  digit in the number.\n- This leaves **46 additional values**, which are significant in the encoding.\n- The digits in a number are ordered from **high to low significance**.\n\n## Usage\n\n### Encoding \u0026 Decoding Example\n\n```ts\nimport {\n  encodeVarbytePrintable,\n  decodeVarbytePrintable,\n} from \"varbyte-printable\";\n\nconst bytes = new Uint16Array([72, 101, 108, 1080, 111]);\nconst encoded = encodeVarbytePrintable(bytes);\nconsole.log(encoded); // T!j#X#`8f#c\n\nconst decoded = decodeVarbytePrintable(Uint16Array, encoded);\nconsole.log(decoded); // Uint16Array(5) [72, 101, 108, 1080, 111]\n```\n\n## Development\n\nTo build the project locally:\n\n```sh\ngit clone https://github.com/binhtran432k/varbyte-printable.git\ncd varbyte-printable\nbun install\nbun gen\n```\n\nTo run test:\n\n```sh\nbun test\n```\n\n## References\n\n- [Lezer by Marijn Haverbeke](https://github.com/lezer-parser) - Algorithm inspiration.\n- [Bun](https://bun.sh/) - Build and runtime support.\n- [oxc-transform](https://github.com/oxc-project/oxc) - TypeScript\n  transformation tool.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinhtran432k%2Fvarbyte-printable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinhtran432k%2Fvarbyte-printable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinhtran432k%2Fvarbyte-printable/lists"}