{"_id":"@common-creation/z85-wasm","_rev":"2-1fb0798369202c4caff6d35c46b4d66e","name":"@common-creation/z85-wasm","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@common-creation/z85-wasm","version":"0.1.0","keywords":["z85","encoding","decoding","wasm","webassembly","base85"],"author":{"name":"Common Creation, Co., Ltd."},"license":"MIT","_id":"@common-creation/z85-wasm@0.1.0","maintainers":[{"name":"mohemohe","email":"mohemohe@ghippos.net"}],"homepage":"https://github.com/common-creation/z85-wasm#readme","bugs":{"url":"https://github.com/common-creation/z85-wasm/issues"},"dist":{"shasum":"d09dd6f2cbd6cc01e16eb0f9563a9b9c60e3e6ea","tarball":"https://registry.npmjs.org/@common-creation/z85-wasm/-/z85-wasm-0.1.0.tgz","fileCount":5,"integrity":"sha512-TQd1jDHCdV5teDxCFc4xjw5G6Y21dIDiPt0wEgJC1kAikGYSjoxgJupRJifbPbjz/W2p1YEbOut8UmcmlRm//w==","signatures":[{"sig":"MEUCIQCvd7PfDd69MGV0n+lFDZN+SsiIooR1XvRkPxPg5HWRJgIgA0/l+eawq0rL3jlBgABYn+jnBHcpTGTH0lr9uMPh758=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9585},"main":"pkg/z85_wasm.js","types":"pkg/z85_wasm.d.ts","module":"pkg/z85_wasm.js","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./pkg/z85_wasm.d.ts","import":"./pkg/z85_wasm.js","require":"./pkg/z85_wasm.js"},"./node":{"types":"./node.d.ts","import":"./node.js","require":"./node.js"},"./package.json":"./package.json"},"gitHead":"33723a11649110a8a9901cc7f7688823fdb32f8e","scripts":{"test":"npm run build:node && jest","build":"wasm-pack build --release --target web --out-dir pkg","clean":"rm -rf pkg pkg-node target","test:rust":"cargo llvm-cov","test:wasm":"wasm-pack test --lib","build:node":"wasm-pack build --release --target nodejs --out-dir pkg-node","build:debug":"wasm-pack build --dev --target web --out-dir pkg","prepublishOnly":"npm run build && npm run build:node"},"_npmUser":{"name":"mohemohe","actor":{"name":"mohemohe","type":"user","email":"mohemohe@ghippos.net"},"email":"mohemohe@ghippos.net"},"repository":{"url":"git+https://github.com/common-creation/z85-wasm.git","type":"git"},"_npmVersion":"10.8.2","description":"Z85 encoder/decoder WASM library","directories":{},"_nodeVersion":"20.19.2","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.3","jest":"^29.5.0","ts-jest":"^29.1.0","wasm-pack":"^0.13.1","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/z85-wasm_0.1.0_1751991246156_0.9184002621925096","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@common-creation/z85-wasm","version":"0.1.1","description":"Z85 encoder/decoder WASM library","author":{"name":"Common Creation, Co., Ltd."},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/common-creation/z85-wasm.git"},"main":"pkg/z85_wasm.js","module":"pkg/z85_wasm.js","types":"pkg/z85_wasm.d.ts","exports":{".":{"import":"./pkg/z85_wasm.js","require":"./pkg/z85_wasm.js","types":"./pkg/z85_wasm.d.ts"},"./node":{"import":"./node.js","require":"./node.js","types":"./node.d.ts"},"./package.json":"./package.json"},"scripts":{"build":"wasm-pack build --release --target web --out-dir pkg","build:node":"wasm-pack build --release --target nodejs --out-dir pkg-node","build:debug":"wasm-pack build --dev --target web --out-dir pkg","clean":"rm -rf pkg pkg-node target","test":"npm run build:node && jest","test:rust":"cargo llvm-cov","test:wasm":"wasm-pack test --lib","prepublishOnly":"npm run build && npm run build:node"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"@types/jest":"^29.5.0","@types/node":"^20.0.0","jest":"^29.5.0","ts-jest":"^29.1.0","tsx":"^4.20.3","typescript":"^5.0.0","wasm-pack":"^0.13.1"},"keywords":["z85","encoding","decoding","wasm","webassembly","base85"],"engines":{"node":">=16.0.0"},"_id":"@common-creation/z85-wasm@0.1.1","gitHead":"2332278697097820a33cfe4de4f5518a3a528a6e","bugs":{"url":"https://github.com/common-creation/z85-wasm/issues"},"homepage":"https://github.com/common-creation/z85-wasm#readme","_nodeVersion":"20.19.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-w++gn/ZnQFyYhheY6tvh1l5unh1onMx5HZADHVifwuC3EjrMURUWXTSHElrasQE17ZAF19d/ic9dgGRt8cfmWQ==","shasum":"931b7e23559c5dac30e3fdd10b3fcaee6208061f","tarball":"https://registry.npmjs.org/@common-creation/z85-wasm/-/z85-wasm-0.1.1.tgz","fileCount":13,"unpackedSize":178815,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDhnKGzGTbbLYoeflwZsSHbZn/s+0TD2Gz8nYZFENOCWgIhAJgQ0LsiLiX4nay2z4vl8ovtt4vUqcnlj/34WpOUdAhb"}]},"_npmUser":{"name":"mohemohe","email":"mohemohe@ghippos.net","actor":{"name":"mohemohe","email":"mohemohe@ghippos.net","type":"user"}},"directories":{},"maintainers":[{"name":"mohemohe","email":"mohemohe@ghippos.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/z85-wasm_0.1.1_1752021525142_0.8755920515587392"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-08T16:14:06.076Z","modified":"2025-07-09T00:38:45.525Z","0.1.0":"2025-07-08T16:14:06.326Z","0.1.1":"2025-07-09T00:38:45.322Z"},"bugs":{"url":"https://github.com/common-creation/z85-wasm/issues"},"author":{"name":"Common Creation, Co., Ltd."},"license":"MIT","homepage":"https://github.com/common-creation/z85-wasm#readme","keywords":["z85","encoding","decoding","wasm","webassembly","base85"],"repository":{"type":"git","url":"git+https://github.com/common-creation/z85-wasm.git"},"description":"Z85 encoder/decoder WASM library","maintainers":[{"name":"mohemohe","email":"mohemohe@ghippos.net"}],"readme":"# @common-creation/z85-wasm\n\nA WebAssembly-based Z85 encoder/decoder library that provides efficient encoding and decoding of binary data using the Z85 format (ZeroMQ spec:32/Z85).\n\n## Features\n\n- ✅ Full Z85 encoding and decoding support\n- ✅ Automatic padding handling (Z85 requires data length divisible by 4)\n- ✅ Base64 ↔ Z85 conversion utilities\n- ✅ TypeScript support with full type definitions\n- ✅ Optimized WASM implementation for performance\n- ✅ ~6.67% bandwidth savings compared to Base64\n\n## Installation\n\nInstall from npm:\n\n```bash\nnpm install @common-creation/z85-wasm\n```\n\nOr install from GitHub (development version):\n\n```bash\nnpm install github:common-creation/z85-wasm\n```\n\n## Usage\n\n### Basic Example\n\n```javascript\nimport init, { z85_to_base64, base64_to_z85, encode_z85, decode_z85 } from '@common-creation/z85-wasm';\n\n// Initialize the WASM module (required before using any functions)\nawait init();\n\n// Convert between Base64 and Z85\nconst base64Data = \"SGVsbG8gV29ybGQ=\"; // \"Hello World\" in base64\nconst z85Data = await base64_to_z85(base64Data);\nconsole.log(z85Data); // Output: \"87cURD_*#TDfAS:0\"\n\n// Convert back\nconst base64Again = await z85_to_base64(z85Data);\nconsole.log(base64Again); // Output: \"SGVsbG8gV29ybGQ=\"\n\n// Encode raw bytes\nconst rawData = new TextEncoder().encode(\"Hello, World!\");\nconst encoded = await encode_z85(rawData);\nconsole.log(encoded); // Z85 encoded with padding info\n\n// Decode back to raw bytes\nconst decoded = await decode_z85(encoded);\nconsole.log(new TextDecoder().decode(decoded)); // Output: \"Hello, World!\"\n```\n\n### TypeScript Example\n\n```typescript\nimport init, { \n  z85_to_base64, \n  base64_to_z85, \n  encode_z85, \n  decode_z85,\n  get_encoding_efficiency \n} from '@common-creation/z85-wasm';\n\nasync function example() {\n  await init();\n  \n  // Get encoding efficiency stats\n  const stats = get_encoding_efficiency(100000); // 100KB\n  console.log(stats);\n  // {\n  //   original_size: 100000,\n  //   base64_size: 133336,\n  //   z85_size: 125000,\n  //   efficiency_ratio: 0.9375,\n  //   bandwidth_saving: 6.25\n  // }\n}\n```\n\n## API Reference\n\n### Core Types\n\n```typescript\nenum DataType {\n  Raw,      // Raw data format (default)\n  DataURL   // Data URL format (e.g., data:image/png;base64,...)\n}\n\nclass ConversionOptions {\n  constructor(input: DataType, output: DataType);\n  input: DataType;\n  output: DataType;\n}\n```\n\n### Functions\n\n#### `init(): Promise<void>`\nInitialize the WASM module. Must be called before using any other functions. This is the default export that initializes the WebAssembly module asynchronously.\n\n#### `initSync(): void`\nAlternative synchronous initialization method. Use this when you need to initialize the module synchronously (e.g., in certain bundler configurations).\n\n#### `init_wasm(): void`\nInternal initialization function that's automatically called when the WASM module loads. You typically don't need to call this directly - use `init()` instead.\n\n#### `z85_to_base64(z85_data_with_padding: string): string`\nConvert Z85 encoded data (with padding info) to Base64.\n\n#### `z85_to_base64_with_options(data: string, options?: ConversionOptions): string`\nConvert Z85 to Base64 with format options. Supports Data URL conversion.\n\n```javascript\n// Data URL to Data URL\nconst result = await z85_to_base64_with_options(\n  \"data:image/png;z85,encoded:0\",\n  new ConversionOptions(DataType.DataURL, DataType.DataURL)\n);\n// → \"data:image/png;base64,...\"\n\n// Data URL to Raw\nconst result = await z85_to_base64_with_options(\n  \"data:image/jpeg;z85,encoded:0\",\n  new ConversionOptions(DataType.DataURL, DataType.Raw)\n);\n// → \"base64data\"\n```\n\n#### `base64_to_z85(base64_data: string): string`\nConvert Base64 encoded data to Z85 with padding info.\n\n#### `base64_to_z85_with_options(data: string, options?: ConversionOptions): string`\nConvert Base64 to Z85 with format options. Supports Data URL conversion.\n\n```javascript\n// Data URL to Data URL\nconst result = await base64_to_z85_with_options(\n  \"data:image/png;base64,iVBORw0...\",\n  new ConversionOptions(DataType.DataURL, DataType.DataURL)\n);\n// → \"data:image/png;z85,...\"\n```\n\n#### `encode_z85(data: Uint8Array): string`\nEncode raw bytes to Z85 format with padding info.\n\n#### `decode_z85(z85_data_with_padding: string): Uint8Array`\nDecode Z85 data (with padding info) to raw bytes.\n\n#### `get_encoding_efficiency(original_size: number): object`\nCalculate encoding efficiency comparison between Base64 and Z85.\n\n## Z85 Format\n\nThis library uses the Z85 format as specified in [ZeroMQ RFC 32](https://rfc.zeromq.org/spec/32/). The implementation includes automatic padding handling:\n\n- Z85 requires input length to be divisible by 4\n- Padding bytes are automatically added during encoding\n- Padding information is preserved in the format: `{z85_data}:{padding_count}`\n- Padding is automatically removed during decoding\n\n## Development\n\n### Building from Source\n\n```bash\n# Clone the repository\ngit clone https://github.com/common-creation/z85-wasm.git\ncd z85-wasm\n\n# Install dependencies\nnpm install\n\n# Build WASM module\nnpm run build\n\n# Run tests\nnpm test\n```\n\n### Publishing\n\nThe package is automatically published to npm when a new tag is pushed:\n\n```bash\ngit tag v1.0.1\ngit push origin v1.0.1\n```\n\n### Setting up npm Token\n\nTo enable automated publishing, add your npm token as a GitHub secret:\n\n1. Get your npm token: `npm token create`\n2. Add it to GitHub: Settings → Secrets → New repository secret\n3. Name: `NPM_TOKEN`\n4. Value: Your npm token\n\n## Requirements\n\n- Node.js >= 16.0.0\n- Rust toolchain (for building from source)\n- wasm-pack (installed automatically during build)\n\n## License\n\nMIT\n\n## Contributing\n\nIssues and pull requests are welcome at the [GitHub repository](https://github.com/common-creation/z85-wasm).","readmeFilename":"README.md"}