{"id":15449041,"url":"https://github.com/hazae41/bytes","last_synced_at":"2026-03-17T15:24:35.895Z","repository":{"id":65724828,"uuid":"598224491","full_name":"hazae41/bytes","owner":"hazae41","description":"Utilities to deal with Uint8Array","archived":false,"fork":false,"pushed_at":"2025-08-11T14:23:52.000Z","size":2521,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-28T02:50:58.359Z","etag":null,"topics":["buffer","bytes","helpers","javascript","typescript","uint8array","utilities","web"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["hazae41"],"patreon":"hazae41"}},"created_at":"2023-02-06T17:01:43.000Z","updated_at":"2025-08-11T14:23:56.000Z","dependencies_parsed_at":"2025-03-03T04:30:48.831Z","dependency_job_id":"52e491ff-c147-450a-872a-c2520eec624e","html_url":"https://github.com/hazae41/bytes","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"b38ded79c2c432a6ed031d44eb3f5782208ee476"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/hazae41/bytes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fbytes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fbytes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fbytes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fbytes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hazae41","download_url":"https://codeload.github.com/hazae41/bytes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fbytes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30626812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T14:16:03.965Z","status":"ssl_error","status_checked_at":"2026-03-17T14:16:03.380Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["buffer","bytes","helpers","javascript","typescript","uint8array","utilities","web"],"created_at":"2024-10-01T20:42:15.304Z","updated_at":"2026-03-17T15:24:35.854Z","avatar_url":"https://github.com/hazae41.png","language":"TypeScript","funding_links":["https://github.com/sponsors/hazae41","https://patreon.com/hazae41"],"categories":[],"sub_categories":[],"readme":"# Bytes\n\nUtilities to deal with sized Uint8Array\n\n```bash\nnpm i @hazae41/bytes\n```\n\n[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/bytes)\n\n## Features\n- 100% TypeScript and ESM\n- Rust-like patterns\n- Strongly typed Uint8Array and ArrayLike size\n- Zero-cost abstraction over Uint8Array and ArrayLike\n- Zero-copy conversion from ArrayBufferView\n- Use native Buffer for faster execution on Node\n- Unit-tested\n\n## Usage\n\n#### Sized bytes\n\n```tsx\nconst bytes8 = Bytes.alloc(8) // Bytes\u003c8\u003e\n```\n\n#### Unsafe-allocated sized bytes\n\n```tsx\nconst bytes8 = Bytes.allocUnsafe(8) // Bytes\u003c8\u003e\n```\n\n#### Random sized bytes\n\n```tsx\nconst bytes8 = Bytes.random(8) // Bytes\u003c8\u003e\n```\n\n#### Unknown-sized bytes\n\n```tsx\nconst bytesX = new Uint8Array(8) // Bytes\u003cnumber\u003e\n```\n\n#### Runtime type-guarding\n\n```tsx\nif (Bytes.is(bytesX, 8))\n  bytesX // Bytes\u003c8\u003e\nelse\n  bytesX // Bytes\u003cnumber\u003e\n```\n\n#### Type-guarded runtime equality check\n\n```tsx\nif (Bytes.equals(bytesX, bytes8))\n  bytesX // Bytes\u003c8\u003e\nelse\n  bytesX // Bytes\u003cnumber\u003e\n```\n\n#### Runtime casting with Result pattern\n\n```tsx\nconst bytes16 = Bytes.tryCast(bytesX, 16).unwrap() // Bytes\u003c16\u003e\n```\n\n#### Conversion from sized arrays\n\n```tsx\nconst sized4 = Sized.cast([1, 2, 3, 4], 4).unwrap() // Sized\u003c4\u003e\nconst bytes4 = Bytes.from(sized4) // Bytes\u003c4\u003e\n```\n\n#### Utf8, Hex, Base64, Ascii encoding\n\n```tsx\nBytes.fromUtf8(Bytes.toUtf8(bytesX))\n```\n\n```tsx\nBytes.fromHex(Bytes.toHex(bytesX))\n```\n\n```tsx\nBytes.fromBase64(Bytes.toBase64(bytesX))\n```\n\n```tsx\nBytes.fromAscii(Bytes.toAscii(bytesX))\n```\n\n#### BigInt conversion\n\n```tsx\nBytes.fromBigInt(Bytes.toBigInt(bytesX))\n```\n\n#### Sized slicing and padding\n\n```tsx\nconst bytes8 = Bytes.sliceOrPadStart(bytesX, 8) // Bytes\u003c8\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazae41%2Fbytes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhazae41%2Fbytes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazae41%2Fbytes/lists"}