{"_id":"@1-/z85","_rev":"3-9b7ecb2a496ef77a225f75de342e3d2b","name":"@1-/z85","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@1-/z85","version":"0.1.0","keywords":[],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/z85@0.1.0","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/z85","bugs":{"url":"https://github.com/webc-site/npm/issues"},"dist":{"shasum":"0862b02870eb918ccb3541d850081e05a6cf9aaf","tarball":"https://registry.npmjs.org/@1-/z85/-/z85-0.1.0.tgz","fileCount":4,"integrity":"sha512-ENuC7mh9/Gd66IrrPkbC+TPvbxu3l4UpwdV6VQltwOKvISOEZAiHyRPF7sHJHrwkM0h7UCPKbp1PqiGBSOEnNw==","signatures":[{"sig":"MEQCIBLSXyjG13/aSXgbHFeBCrhemDMX+VRLUesgG+BOg4+nAiBvkr3BavfTRke/HL/FCLEFFcOalOwnROKT+8JOMUV4Xg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5845},"knip":{"entry":["tests/_.test.js","bench/*.bench.js"]},"type":"module","exports":{"./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"[English](#en) | [中文](#zh)","directories":{},"_nodeVersion":"26.2.0","dependencies":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/z85_0.1.0_1781167987835_0.53062219338608","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@1-/z85","version":"0.1.1","keywords":["z85","base85","encoding","decoding","zeromq"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/z85@0.1.1","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/z85","bugs":{"url":"https://github.com/webc-site/npm/issues"},"dist":{"shasum":"8786e12b58b29f12eda1e646207406f8ab609d52","tarball":"https://registry.npmjs.org/@1-/z85/-/z85-0.1.1.tgz","fileCount":4,"integrity":"sha512-wKqIuL4GNwh2bHZKYpkUr7WI8EO8kot68g4DuxMUeueByf+OXcONku9C++8Fjp7JW4345QgtG3lGO7sLkbIWkQ==","signatures":[{"sig":"MEUCIQDhA0tOoieSlZhg0O50PZBBYj+Sg8Uqg5GTN21TGAdNHwIgWBHmplCJL0Z1AmncGLukCNlYLCmBdSeItC4TWnXSXcI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8873},"knip":{"entry":["tests/_.test.js","bench/*.bench.js"]},"type":"module","exports":{"./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"A blazing fast, ultra-lightweight, and zero-dependency Z85 (ZeroMQ Base-85) encoder/decoder library.","directories":{},"_nodeVersion":"26.2.0","dependencies":{},"_hasShrinkwrap":false,"description:zh":"极速、超轻量、无依赖的 Z85 (ZeroMQ Base-85) 编解码库。","_npmOperationalInternal":{"tmp":"tmp/z85_0.1.1_1781169018616_0.7576110391428439","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@1-/z85","version":"0.1.2","description":"A blazing fast, ultra-lightweight, and zero-dependency Z85 (ZeroMQ Base-85) encoder/decoder library.","keywords":["base85","decoding","encoding","z85","zeromq"],"homepage":"https://github.com/webc-site/npm/tree/main/z85","license":"MulanPSL-2.0","author":{"name":"x-at-01@googlegroups.com"},"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"type":"module","exports":{"./*":"./*"},"dependencies":{},"description:zh":"极速、超轻量、无依赖的 Z85 (ZeroMQ Base-85) 编解码库。","knip":{"entry":["tests/_.test.js","bench/*.bench.js"]},"_id":"@1-/z85@0.1.2","bugs":{"url":"https://github.com/webc-site/npm/issues"},"_nodeVersion":"26.2.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-OplRW8CL6/TmoBElkRWkYSEU3opmkhnbuTZpMTq2hYja+i4UpGdqaZPqN0RVEpeJtgTPg9kiW0WFvcgd+gOTVw==","shasum":"2d681f7d3e8dac77ff0c3ab8bcbd2d75e14feff0","tarball":"https://registry.npmjs.org/@1-/z85/-/z85-0.1.2.tgz","fileCount":5,"unpackedSize":9456,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHXr9noNrfFEhBElupvp0oUtNovgPJSSYHybIx/DEkxqAiAYlJr0jYkzW+m6pHnnhPGE4ly0yR7qXEUJTw9kje2eWw=="}]},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"directories":{},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/z85_0.1.2_1781170891483_0.6030141200530152"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-11T08:53:07.688Z","modified":"2026-06-11T09:41:31.758Z","0.1.0":"2026-06-11T08:53:07.957Z","0.1.1":"2026-06-11T09:10:18.767Z","0.1.2":"2026-06-11T09:41:31.606Z"},"bugs":{"url":"https://github.com/webc-site/npm/issues"},"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","homepage":"https://github.com/webc-site/npm/tree/main/z85","keywords":["base85","decoding","encoding","z85","zeromq"],"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"description":"A blazing fast, ultra-lightweight, and zero-dependency Z85 (ZeroMQ Base-85) encoder/decoder library.","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"readme":"[English](#en) | [中文](#zh)\n\n---\n\n<a id=\"en\"></a>\n# @1-/z85 : Ultra-Fast and Minimal Z85 Encoding and Decoding Implementation\n\n- [@1-/z85 : Ultra-Fast and Minimal Z85 Encoding and Decoding Implementation](#1-z85-ultra-fast-and-minimal-z85-encoding-and-decoding-implementation)\n  - [Functionality](#functionality)\n  - [Usage](#usage)\n    - [Install](#install)\n    - [Encoding](#encoding)\n    - [Decoding](#decoding)\n  - [Design Rationale](#design-rationale)\n  - [Technology Stack](#technology-stack)\n  - [Code Structure](#code-structure)\n  - [Historical Context](#historical-context)\n  - [About](#about)\n\n## Functionality\n\nProvides Z85 encoding and decoding compliant with ZeroMQ RFC 32. Solves the problem of excessive bundle size and suboptimal performance in general-purpose Base85 libraries for browsers and lightweight runtimes, achieving industry-leading metrics through algorithmic optimization and zero-dependency design.\n\n## Usage\n\n### Install\n\n```bash\nnpm install @1-/z85\n```\n\n### Encoding\n\nEncodes a `Uint8Array` to a Z85-encoded `Uint8Array`. The input length must be a multiple of 4.\n\n```javascript\nimport z85e from \"@1-/z85/src/z85e.js\";\n\nconst data = new Uint8Array([1, 2, 3, 4]);\nconst encoded = z85e(data);\n// Returns Uint8Array(5) [ 48, 48, 48, 48, 103 ] (represents string \"0000g\")\n```\n\n### Decoding\n\nDecodes a Z85-encoded `Uint8Array` back to a `Uint8Array`. The input length must be a multiple of 5.\n\n```javascript\nimport z85d from \"@1-/z85/src/z85d.js\";\n\nconst decoded = z85d(encoded);\n// Returns Uint8Array(4) [ 1, 2, 3, 4 ]\n```\n\n## Design Rationale\n\nThe library uses a hybrid table-lookup and bit-manipulation approach, refactored with low-coupling and high-cohesion principles to extract and reuse common assets:\n\n- **Common Module** (`_.js`): Defines the standard Z85 character set and converts it to UTF-8 encoded bytes, shared by both the encoder and decoder.\n- **Encoder** (`z85e.js`): Imports the character mapping table from the common module, performing five modulo-85 operations and table-lookups per 32-bit unsigned integer, utilizing `>>> 0` and `| 0` for bitwise operations and truncation.\n- **Decoder** (`z85d.js`): Imports the character set from the common module. Precomputes dual-layer lookup tables upon module load: a first-tier `DECODE_MAP` (256-byte `Int8Array`) for fast single-byte validation, and a second-tier `DECODE_MAP_2` (65536-byte `Int16Array`) mapping all double-byte combinations (85×85=7225) to their values. This decomposes 5-byte decoding into three lookups and two multiply-add operations.\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@rZ/bazGswXDTmnZA3ls9h-w.svg)\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@XM/WpPz1-L8yGlHWz-MQrZw.svg)\n\n## Technology Stack\n\n- Runtime: Standard ECMAScript 2022 (ES13)\n- External Dependency: None\n\n## Code Structure\n\n```\nsrc/\n├── _.js        # Z85 Shared character set table (UTF-8 encoded)\n├── z85e.js     # Primary Z85 encoder logic\n└── z85d.js     # Primary Z85 decoder logic\n```\n\n## Historical Context\n\nZ85 encoding was designed by Pieter Hintjens in 2011 for the ZeroMQ protocol as a replacement for Base64 and Ascii85. Its key innovation is the selection of 85 printable ASCII characters (0–9, a–z, A–Z, .-:+=^!/*?&<>()[]{}@%$#), reducing encoded data size by ~12% compared to Base64 while completely avoiding the parsing ambiguity introduced by the `z` character in Ascii85. RFC 32 formally standardized it, establishing Z85 as the de facto standard for textual binary data transport within the ZeroMQ ecosystem.\n\n## About\n\nThis library is developed by [WebC.site](https://webc.site).\n\n[WebC.site](https://webc.site): A new paradigm of web development for AI\n\n\n---\n\n<a id=\"zh\"></a>\n# @1-/z85 : 极速、超轻量、零依赖的 Z85 编解码实现\n\n- [@1-/z85 : 极速、超轻量、零依赖的 Z85 编解码实现](#1-z85-极速超轻量零依赖的-z85-编解码实现)\n  - [功能介绍](#功能介绍)\n  - [使用演示](#使用演示)\n    - [安装](#安装)\n    - [编码](#编码)\n    - [解码](#解码)\n  - [设计思路](#设计思路)\n  - [技术栈](#技术栈)\n  - [代码结构](#代码结构)\n  - [历史故事](#历史故事)\n  - [关于](#关于)\n\n## 功能介绍\n\n提供符合 ZeroMQ RFC 32 规范的 Z85 编码与解码功能。解决通用 Base85 库在浏览器与轻量级运行时中体积过大、性能不足的问题，通过算法优化与零依赖设计，达成业界领先的体积与吞吐量指标。\n\n## 使用演示\n\n### 安装\n\n```bash\nnpm install @1-/z85\n```\n\n### 编码\n\n将 `Uint8Array` 编码为 Z85 格式的 `Uint8Array`。输入长度必须是 4 的倍数。\n\n```javascript\nimport z85e from \"@1-/z85/src/z85e.js\";\n\nconst data = new Uint8Array([1, 2, 3, 4]);\nconst encoded = z85e(data);\n// 返回 Uint8Array(5) [ 48, 48, 48, 48, 103 ] (代表字符串 \"0000g\")\n```\n\n### 解码\n\n将 Z85 格式的 `Uint8Array` 解码为原始的 `Uint8Array`。输入长度必须是 5 的倍数。\n\n```javascript\nimport z85d from \"@1-/z85/src/z85d.js\";\n\nconst decoded = z85d(encoded);\n// 返回 Uint8Array(4) [ 1, 2, 3, 4 ]\n```\n\n## 设计思路\n\n本库采用查表法与位运算结合的设计，以低耦合、高内聚为原则进行重构，将公共字符集与工具提取复用：\n\n- **公共模块**（`_.js`）：定义 Z85 标准字符集，并使用 UTF-8 编码转换为字节数组，供编码器和解码器共享。\n- **编码器**（`z85e.js`）：从公共模块导入字符映射表，对每个 32 位无符号整数进行五次模除与查表操作，辅以 `>>> 0` 与 `| 0` 进行位运算及截断。\n- **解码器**（`z85d.js`）：从公共模块导入字符集。在模块加载时预计算双层查表：第一层 `DECODE_MAP`（256 字节 `Int8Array`）用于快速单字节合法性校验；第二层 `DECODE_MAP_2`（65536 字节 `Int16Array`）预计算所有双字节组合的值（85×85=7225）。将五字节解码操作简化为三次查表与两次乘加运算。\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@_u/RfpnizrZzDqrFenM6ThQ.svg)\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@pY/bIlymBThd2iAQsEz3NPA.svg)\n\n## 技术栈\n\n- 运行时：标准 ECMAScript 2022（ES13）\n- 外部依赖：无\n\n## 代码结构\n\n```\nsrc/\n├── _.js        # Z85 共享字符集表（UTF-8 编码）\n├── z85e.js     # Z85 编码器主逻辑\n└── z85d.js     # Z85 解码器主逻辑\n```\n\n## 历史故事\n\nZ85 编码由 Pieter Hintjens 于 2011 年为 ZeroMQ 协议设计，旨在替代 Base64 和 Ascii85。其核心创新在于选用 85 个可打印 ASCII 字符（0–9, a–z, A–Z, .-:+=^!/*?&<>()[]{}@%$#），使编码后数据体积比 Base64 减少约 12%，且完全规避了 Ascii85 中因 `z` 字符导致的解析歧义问题。RFC 32 将其正式标准化，成为 ZeroMQ 生态中二进制数据文本化传输的事实标准。\n\n## 关于\n\n本库由 [WebC.site](https://webc.site) 开发。\n\n[WebC.site](https://webc.site) : 面向人工智能的网站开发新范式\n\n","readmeFilename":"README.md"}