{"_id":"zeck","_rev":"18-a4558ec73beb01e656416072dc7aeede","name":"zeck","dist-tags":{"latest":"3.0.1"},"versions":{"0.1.0":{"name":"zeck","version":"0.1.0","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@0.1.0","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"48f191f69901eeef80e5ef7380a9921959f4ef35","tarball":"https://registry.npmjs.org/zeck/-/zeck-0.1.0.tgz","fileCount":7,"integrity":"sha512-ukMRK//f0JxIlLdxuGKzjsZxOilg2HgAXpKxbR6BVS09POoeA9XMTNbvWoOhKTlI+hXwFE36hYmvAshVtrGxEA==","signatures":[{"sig":"MEUCIH6srlurMj7J2yX3gWLDWcz2RAp9cklisLSdvDk20qwUAiEAsg+shI5CfrZv/l5qds3DnJeuvM+Lr5TJBvVHoqpnrgg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":90808},"main":"zeckendorf_rs.js","type":"module","types":"zeckendorf_rs.d.ts","gitHead":"4814e0a87c9771e9a296759c24a17ae8d3e3a4cf","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeckendorf_rs.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_0.1.0_1767385154019_0.8046383518532754","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"zeck","version":"0.2.0","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@0.2.0","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"74280fc1295a876c8e9345a2a0c8d67db5ff5100","tarball":"https://registry.npmjs.org/zeck/-/zeck-0.2.0.tgz","fileCount":7,"integrity":"sha512-+izJOqdd+opMekIWkt90J51LT02toHS0kiEASuSUlX8gSW5FqzEc5voADlz5EcClXQw+BdDeePbt0UzjDd79CQ==","signatures":[{"sig":"MEUCID4X05egHdQ9R0YIrX3tzw5fGLLc5VceFTgBxqU+HirOAiEA9zymIGEAwdK3f03bttkB3UM398+TgbSD/X8jyTBo24A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":96691},"main":"zeck.js","type":"module","types":"zeck.d.ts","gitHead":"d663ba9736284b3de94db37a6fc99c6b46a44b53","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeck.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_0.2.0_1767461115542_0.9845811249509036","host":"s3://npm-registry-packages-npm-production"}},"1.0.7":{"name":"zeck","version":"1.0.7","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@1.0.7","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"9f8039c230e9459cde890e23319df9372c1bc920","tarball":"https://registry.npmjs.org/zeck/-/zeck-1.0.7.tgz","fileCount":7,"integrity":"sha512-z8FCQfQkUxMt2edo6qRaEQJs40zNaZP7+QImq/OjUGQppLIBldGjvjLHZ0VoKgN5t8UfRlbX7RCmOE0QlHma3w==","signatures":[{"sig":"MEUCIQD5xpumjFnh0dknD8Tot/OXRlIYm3F5FYIpC2K9hfjDQQIgP1xh/fnTqzwB5CT/6DSAsu2Q1okEUKoFFIVlXNU3j6Y=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":100927},"main":"zeck.js","type":"module","types":"zeck.d.ts","gitHead":"045ecbc9ac029be8baf7fe17ec65c46111e693cf","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeck.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_1.0.7_1767489072219_0.3037919284346169","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"zeck","version":"2.0.0","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@2.0.0","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"dc01a1eb3b19ca39346d5ab359f3cb088d506f8b","tarball":"https://registry.npmjs.org/zeck/-/zeck-2.0.0.tgz","fileCount":7,"integrity":"sha512-RSGRQN6Sf8ZlXoHRdGVAd/GznmelQGnbhZhyFkYfxE4nd3sZ1joZucQzOSQy4cbG/3MX2u4pAfdRFwVYxy0+Qg==","signatures":[{"sig":"MEUCIAY+rhtTyulN2ohLHQ9j/Cp7dTydas6rPbfeAA7x5fC8AiEAlZPPGEvmZ9sXQcUprNE4srgLRHZaPY46MDBRO27tcck=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":107060},"main":"zeck.js","type":"module","types":"zeck.d.ts","gitHead":"2ca209fc792d9397c5a5a0c7a882fded4c5e4a56","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeck.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_2.0.0_1767564558658_0.8717807297466997","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"name":"zeck","version":"2.1.0","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@2.1.0","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"9574250c65951ae56ac56ca99103991f16a1c351","tarball":"https://registry.npmjs.org/zeck/-/zeck-2.1.0.tgz","fileCount":7,"integrity":"sha512-9la/ja/XweSfw3kpCXoOVFEoJEmrHeesNAu39wTEWwuKzYb7Y0IKvJ3bMTsio4mx1cXdXeQjjSP9dvsJE1heoA==","signatures":[{"sig":"MEYCIQCyIYlsbCCDWuG5AHfpKlTJDS2TsxJeOVUj00Q9rFAi9AIhALPrgIoOECLYhGZZdAQjp8Ze1wm6/uSe7jFExg5QlDcL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":134045},"main":"zeck.js","type":"module","types":"zeck.d.ts","gitHead":"fb039051aab9a1f7ab6abc5c5f1d6ee9977a6258","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeck.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_2.1.0_1767574545672_0.8387452386720795","host":"s3://npm-registry-packages-npm-production"}},"2.1.1":{"name":"zeck","version":"2.1.1","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@2.1.1","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"35e1959dbed8f6cab844293884fc2c2efc4c3246","tarball":"https://registry.npmjs.org/zeck/-/zeck-2.1.1.tgz","fileCount":7,"integrity":"sha512-X2hRm7JEjAd1XfX2qg47Gaf3UQQkAvU9yGUnzbXIA8++TsEGaci5pL4RKpeJ+BxVeF9MoPb//cuLXGABPjrMCA==","signatures":[{"sig":"MEUCIQDjQ9zKAXt4CfOHVgOrd1L9e8u75H/D1m5jUfVqYree2wIgR23qZH/RwewGKBTmPtcxv2z4xvuIUDeiNgrE0a7KHjI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":232876},"main":"zeck.js","type":"module","types":"zeck.d.ts","gitHead":"54ac0251c8ecb716e47b9f2287bf798709ccfd11","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeck.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_2.1.1_1767592780204_0.8039872833703952","host":"s3://npm-registry-packages-npm-production"}},"2.1.2":{"name":"zeck","version":"2.1.2","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@2.1.2","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"a9e59cbc15a8f1665e3de4517f2bcb761b54aa83","tarball":"https://registry.npmjs.org/zeck/-/zeck-2.1.2.tgz","fileCount":7,"integrity":"sha512-dqYnk5P6Raz6Xka37HAruqKuavlUC7PIPxQbIBC0FOu9/jhd4fWceA+h5N5/EgMEkcmPVxOdXdoiketquk73zQ==","signatures":[{"sig":"MEYCIQDX7zjcdttcdrmDGK7VEvR5n+5gjaLCuTrcv/zAsBCDPgIhALbfpv6BR9S9Gc0xS6wPt3Mhj7uFKNlT9dyP441+xeEg","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":231589},"main":"zeck.js","type":"module","types":"zeck.d.ts","gitHead":"31dca666ca495fcbae5bc59747ceb41448751688","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeck.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_2.1.2_1767595017581_0.9349080633702203","host":"s3://npm-registry-packages-npm-production"}},"2.1.3":{"name":"zeck","version":"2.1.3","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@2.1.3","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"ab89c13cb6cd34d1535f5501246e4cb257277b73","tarball":"https://registry.npmjs.org/zeck/-/zeck-2.1.3.tgz","fileCount":7,"integrity":"sha512-vr/kpr6BJesUvxkjMoODHWCEn7IHnrrP4bvHYQ93WLpGVOtpnLQ4kmErh4VyU9Ga7feiw05mFnRYahK34tyV2w==","signatures":[{"sig":"MEQCIEwSdQsZa3R1kNSuUFSXp8V4JB1lE7khOqVve2YrN54+AiB3TS7FG95ECrG8LkbsPl+gS3WS77eofGlFiB0TvAYAMQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":231589},"main":"zeck.js","type":"module","types":"zeck.d.ts","gitHead":"70662438c4d81700f5d752a9f85cfdc3618a2d01","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeck.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_2.1.3_1767736395825_0.8021687908511679","host":"s3://npm-registry-packages-npm-production"}},"3.0.0":{"name":"zeck","version":"3.0.0","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"license":"MIT","_id":"zeck@3.0.0","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"homepage":"https://github.com/pRizz/zeckendorf#readme","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"dist":{"shasum":"b7a44050f5a2f42827e00836c8c529f33ce8ef06","tarball":"https://registry.npmjs.org/zeck/-/zeck-3.0.0.tgz","fileCount":7,"integrity":"sha512-GObtUG+/MRU6MBkBpQeIrBRsLP4YyxHbuEU285T6R6V7tB99gxgn0mUxDTD9wne3dBEnzJ+gwKUD8BgTMy6YEg==","signatures":[{"sig":"MEUCIFlUcyYKkgXakqN8zI2vWj2rFOGFl9Klkemc18xyLKM1AiEAyntJF4FZND3j0diYSV3lx9kYIvhD1X/7/8ddstK72AI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":231762},"main":"zeck.js","type":"module","types":"zeck.d.ts","gitHead":"3cf2b76defa63ec19bbbb4df89257396bff0a89e","_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"repository":{"url":"git+https://github.com/pRizz/zeckendorf.git","type":"git"},"_npmVersion":"10.9.2","description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","directories":{},"sideEffects":["./zeck.js","./snippets/*"],"_nodeVersion":"22.14.0","collaborators":["Peter Ryszkiewicz"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zeck_3.0.0_1768052936229_0.5767944404226029","host":"s3://npm-registry-packages-npm-production"}},"3.0.1":{"name":"zeck","type":"module","collaborators":["Peter Ryszkiewicz"],"description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","version":"3.0.1","license":"MIT","repository":{"type":"git","url":"git+https://github.com/pRizz/zeckendorf.git"},"main":"zeck.js","types":"zeck.d.ts","sideEffects":["./zeck.js","./snippets/*"],"keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"_id":"zeck@3.0.1","gitHead":"497646c07680cbdcf13b32a40e70b0eafddfafcf","bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"homepage":"https://github.com/pRizz/zeckendorf#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-+cYciKtaEo1zwcxdkt5hIzEg5xrclC/J1jjFw3lyQfzSvsdIBdF/Mn8pufyOMUoNUNvzXeXNkXAUKw0bo0w9EA==","shasum":"2fcf905a2337fc699977435b12a6973961891927","tarball":"https://registry.npmjs.org/zeck/-/zeck-3.0.1.tgz","fileCount":7,"unpackedSize":231891,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDvMuO5OPEGPR/0Gkf6RLsJzMnKgPpajWnMRHAthU0kKgIgfG5MOqD9eqiW4Qo5w+6WjpffmXBl0iHfZdHQHEizZXQ="}]},"_npmUser":{"name":"prizz","email":"pryszkie@gmail.com"},"directories":{},"maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zeck_3.0.1_1768053528708_0.15866773956241453"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-02T20:19:14.018Z","modified":"2026-01-10T13:58:49.061Z","1.0.0":"2024-02-21T14:36:36.292Z","1.0.1":"2024-02-21T15:26:38.621Z","1.0.2":"2024-02-21T15:36:30.258Z","1.0.3":"2024-02-21T15:48:07.853Z","1.0.4":"2024-02-21T15:48:38.804Z","1.0.5":"2024-02-21T16:02:36.339Z","1.0.6":"2024-02-21T16:36:36.643Z","0.1.0":"2026-01-02T20:19:14.175Z","0.2.0":"2026-01-03T17:25:15.702Z","1.0.7":"2026-01-04T01:11:12.376Z","2.0.0":"2026-01-04T22:09:18.819Z","2.1.0":"2026-01-05T00:55:45.808Z","2.1.1":"2026-01-05T05:59:40.365Z","2.1.2":"2026-01-05T06:36:57.728Z","2.1.3":"2026-01-06T21:53:15.989Z","3.0.0":"2026-01-10T13:48:56.407Z","3.0.1":"2026-01-10T13:58:48.862Z"},"bugs":{"url":"https://github.com/pRizz/zeckendorf/issues"},"license":"MIT","homepage":"https://github.com/pRizz/zeckendorf#readme","keywords":["compression","zeckendorf","fibonacci","algorithm","data-compression"],"repository":{"type":"git","url":"git+https://github.com/pRizz/zeckendorf.git"},"description":"A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm","maintainers":[{"name":"prizz","email":"pryszkie@gmail.com"}],"readme":"# Zeckendorf Compression\n\nA Rust library for compressing and decompressing data using the Zeckendorf representation algorithm.\n\n## Overview\n\nThe Zeckendorf algorithm represents numbers as a sum of non-consecutive Fibonacci numbers. This library interprets input data as a big integer (either big-endian or little-endian), converts it to its Zeckendorf representation, and sometimes achieves compression. However, compression is not guaranteed; the algorithm may result in a larger representation depending on the input data. The library can automatically try both endian interpretations and select the one that produces the best compression.\n\n**⚠️ Warning:** Compressing or decompressing files larger than 10KB (10,000 bytes) is unstable due to time and memory pressure. The library may experience performance issues, excessive memory usage, or failures when processing files exceeding this size.\n\n**Command-line tools** (`zeck-compress` and `zeck-decompress`) are available and can be installed via `cargo install zeck`. See the [Binaries](#binaries) section for usage details.\n\n## Features\n\n- **Compression & Decompression**: Convert data to/from Zeckendorf representation\n- **File Format with Headers**: `.zeck` file format that automatically preserves original file size and endianness information\n- **Multiple Endian Interpretations**: Support for both big-endian and little-endian input interpretations\n- **Automatic Best Compression**: Try both endian interpretations and automatically select the best result\n- **Multiple Fibonacci Algorithms**: \n  - Slow recursive (memoized, for small numbers)\n  - Slow iterative (memoized, for large numbers)\n  - Fast Doubling (optimized, ~160x faster for large indices)\n  - Memoized Fast Doubling (with sparse HashMap caching for large, non-contiguous indices)\n- **BigInt Support**: Handle arbitrarily large numbers using `num-bigint`\n- **Memoization**: Thread-safe caching for improved performance\n- **Statistics & Visualization**: Generate compression statistics and plots\n- **Benchmarking**: Comprehensive performance benchmarks\n- **WebAssembly Support**: Available as a WebAssembly module for use in web browsers\n- **Error Handling**: Comprehensive error types for file format operations\n\n## WebAssembly\n\nThis library is also available as a WebAssembly module for use in web browsers and JavaScript/TypeScript projects. The WebAssembly module can be installed via npm:\n\n```bash\nnpm install zeck\n```\n\nAvailable functions are marked with the `#[wasm_bindgen]` attribute. The WebAssembly module can also be built manually using the convenience script at `scripts/build_wasm_bundle.sh` that builds the WebAssembly module with the `wasm-pack` tool.\n\nYou can see a live demo of the WebAssembly module in action at <https://prizz.github.io/zeckendorf-webapp/>. The source code for the demo is available at <https://github.com/pRizz/zeckendorf-webapp>.\n\n## Installation\n\n### Install from crates.io\n\nRun:\n```bash\ncargo add zeck\n```\n\nOr add this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nzeck = \"2.1.0\"\n```\n\n**Features:**\n- `cli_tools`: Enables the `zeck-compress` and `zeck-decompress` command-line binaries. This feature includes the `clap` dependency. Not enabled by default - use `--features cli_tools` when installing binaries.\n\nFor CLI tools (when installing binaries):\n\n```toml\n[dependencies]\nzeck = { version = \"2.1.0\", features = [\"cli_tools\"] }\n```\n\n### Install from GitHub (development version)\n\nRun:\n```bash\ncargo add zeck --git https://github.com/pRizz/zeckendorf\n```\n\nOr add this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nzeck = { git = \"https://github.com/pRizz/zeckendorf\" }\n```\n\nFor CLI tools:\n\n```toml\n[dependencies]\nzeck = { git = \"https://github.com/pRizz/zeckendorf\", features = [\"cli_tools\"] }\n```\n\n### Install from npm\n\nRun:\n```bash\nnpm install zeck\n```\n\nOr add this to your `package.json`:\n\n```json\n{\n  \"dependencies\": {\n    \"zeck\": \"^2.1.0\"\n  }\n}\n```\n\n## Usage\n\n### File Format Compression (Recommended)\n\nThe `.zeck` file format automatically handles size preservation and endianness information. This is the recommended approach for most use cases.\n\n#### Big-Endian File Format\n\n```rust\nuse zeck::zeck_file_format::{compress::compress_zeck_be, decompress::decompress_zeck_file};\n\n// Compress data (interpreted as big-endian integer)\nlet data = vec![12u8];\nlet zeck_file = compress_zeck_be(&data)?;\n\n// Serialize to bytes for storage\nlet bytes = zeck_file.to_bytes();\n\n// Later, deserialize and decompress\nuse zeck::zeck_file_format::file::deserialize_zeck_file;\nlet zeck_file = deserialize_zeck_file(&bytes)?;\nlet decompressed = decompress_zeck_file(&zeck_file)?;\nassert_eq!(data, decompressed);\n```\n\n#### Little-Endian File Format\n\n```rust\nuse zeck::zeck_file_format::{compress::compress_zeck_le, decompress::decompress_zeck_file};\n\n// Compress data (interpreted as little-endian integer)\nlet data = vec![12u8];\nlet zeck_file = compress_zeck_le(&data)?;\n\n// Decompress data\nlet decompressed = decompress_zeck_file(&zeck_file)?;\nassert_eq!(data, decompressed);\n```\n\n#### Automatic Best Compression (File Format)\n\n```rust\nuse zeck::zeck_file_format::{\n    compress::{compress_zeck_best, BestCompressionResult},\n    decompress::decompress_zeck_file,\n};\n\n// Try both endian interpretations and get the best result\nlet data = vec![1, 0];\nmatch compress_zeck_best(&data)? {\n    BestCompressionResult::BigEndianBest { zeck_file, le_size } => {\n        // Big-endian produced the best compression\n        let decompressed = decompress_zeck_file(&zeck_file)?;\n        assert_eq!(data, decompressed);\n    }\n    BestCompressionResult::LittleEndianBest { zeck_file, be_size } => {\n        // Little-endian produced the best compression\n        let decompressed = decompress_zeck_file(&zeck_file)?;\n        assert_eq!(data, decompressed);\n    }\n    BestCompressionResult::Neither { be_size, le_size } => {\n        // Neither method compressed the data (both were larger than original)\n        println!(\"Neither method compressed: BE size = {}, LE size = {}\", be_size, le_size);\n    }\n}\n```\n\n### Padless Compression (Advanced)\n\nThe padless compression functions strip leading zero bytes and do not preserve original size information. **You must manually track the original size** if you need to restore leading zeros. These functions are marked as `_dangerous` to indicate they require careful handling.\n\n**⚠️ Important:** The padless functions are lower-level and do not preserve leading zero bytes. Use the file format functions above for most use cases.\n\n#### Big-Endian Padless\n\n```rust\nuse zeck::{padless_zeckendorf_compress_be_dangerous, padless_zeckendorf_decompress_be_dangerous};\n\n// Compress data (interpreted as big-endian integer)\nlet data = vec![12u8];\nlet compressed = padless_zeckendorf_compress_be_dangerous(&data);\n\n// Decompress data (leading zeros may be lost)\nlet decompressed = padless_zeckendorf_decompress_be_dangerous(&compressed);\n// Note: decompressed may not equal data if data had leading zeros\n```\n\n#### Little-Endian Padless\n\n```rust\nuse zeck::{padless_zeckendorf_compress_le_dangerous, padless_zeckendorf_decompress_le_dangerous};\n\n// Compress data (interpreted as little-endian integer)\nlet data = vec![12u8];\nlet compressed = padless_zeckendorf_compress_le_dangerous(&data);\n\n// Decompress data (trailing zeros may be lost)\nlet decompressed = padless_zeckendorf_decompress_le_dangerous(&compressed);\n```\n\n#### Automatic Best Padless Compression\n\n```rust\nuse zeck::{padless_zeckendorf_compress_best_dangerous, PadlessCompressionResult};\n\nlet data = vec![1, 0];\nmatch padless_zeckendorf_compress_best_dangerous(&data) {\n    PadlessCompressionResult::BigEndianBest { compressed_data, le_size } => {\n        // Use padless_zeckendorf_decompress_be_dangerous for decompression\n    }\n    PadlessCompressionResult::LittleEndianBest { compressed_data, be_size } => {\n        // Use padless_zeckendorf_decompress_le_dangerous for decompression\n    }\n    PadlessCompressionResult::Neither { be_size, le_size } => {\n        // Neither method compressed the data\n    }\n}\n```\n\n### Fibonacci Numbers\n\n```rust\nuse zeck::memoized_slow_fibonacci_recursive;\n\n// Calculate Fibonacci numbers (for indices up to 93)\nlet fib_10 = memoized_slow_fibonacci_recursive(10); // Returns 55\n\n// For larger numbers, use BigInt versions\nuse zeck::fast_doubling_fibonacci_biguint;\nlet fib_100 = fast_doubling_fibonacci_biguint(100);\n\n// For even better performance with caching, use memoized fast doubling\nuse zeck::memoized_fast_doubling_fibonacci_biguint;\nlet fib_1000 = memoized_fast_doubling_fibonacci_biguint(1000);\n```\n\n### Zeckendorf Representation\n\n```rust\nuse zeck::memoized_zeckendorf_list_descending_for_integer;\n\n// Get Zeckendorf representation as a list of Fibonacci indices\nlet zld = memoized_zeckendorf_list_descending_for_integer(12);\n// Returns [6, 4, 2] meaning F(6) + F(4) + F(2) = 8 + 3 + 1 = 12\n\n// For BigInt numbers\nuse zeck::memoized_zeckendorf_list_descending_for_biguint;\nuse num_bigint::BigUint;\nlet zld = memoized_zeckendorf_list_descending_for_biguint(&BigUint::from(12u64));\n```\n\n### Utility Functions\n\nThe library provides various utility functions for working with Fibonacci numbers and Zeckendorf representations:\n\n```rust\nuse zeck::{\n    bit_count_for_number,           // Count bits needed to represent a number\n    highest_one_bit,                 // Get the highest set bit\n    efi_to_fi, fi_to_efi,            // Convert between Effective Fibonacci Index and Fibonacci Index\n    memoized_effective_fibonacci,     // Get Fibonacci number from Effective Fibonacci Index\n    zl_to_ezl, ezl_to_zl,            // Convert between Zeckendorf List and Effective Zeckendorf List\n    all_ones_zeckendorf_to_biguint,   // Create \"all ones\" Zeckendorf numbers\n    PHI, PHI_SQUARED,                 // Golden ratio constants\n};\n```\n\n### Error Handling\n\nThe file format functions return `Result` types with comprehensive error handling:\n\n```rust\nuse zeck::zeck_file_format::{compress::compress_zeck_be, error::ZeckFormatError};\n\nmatch compress_zeck_be(&data) {\n    Ok(zeck_file) => {\n        // Compression succeeded\n    }\n    Err(ZeckFormatError::DataSizeTooLarge { size }) => {\n        // Data size exceeds u64::MAX\n    }\n    Err(e) => {\n        // Handle other errors\n        eprintln!(\"Compression error: {}\", e);\n    }\n}\n```\n\nCommon error types include:\n- `HeaderTooShort`: Input data is too short to contain a valid header\n- `UnsupportedVersion`: File format version is not supported\n- `ReservedFlagsSet`: Reserved flags are set (indicating a newer format)\n- `CompressionFailed`: Compression did not reduce the data size\n- `DecompressedTooLarge`: Decompressed data is larger than expected\n- `DataSizeTooLarge`: Data size exceeds the maximum representable size\n\n## Binaries\n\nThe project includes several utility binaries. The command-line compression tools (`zeck-compress` and `zeck-decompress`) can be installed globally via:\n\n### Install from crates.io\n\n```bash\ncargo install zeck --features cli_tools\n```\n\n### Install from GitHub (development version)\n\n```bash\ncargo install --git https://github.com/pRizz/zeckendorf --features cli_tools zeck\n```\n\nAfter installation, you can use `zeck-compress` and `zeck-decompress` directly from your command line.\n\n### Compression/Decompression Tools\n\n**⚠️ Warning:** Compressing or decompressing files larger than 10KB (10,000 bytes) is unstable due to time and memory pressure. The library may experience performance issues, excessive memory usage, or failures when processing files exceeding this size.\n\n#### zeck-compress\n\nCompresses data using the Zeckendorf representation algorithm. Automatically adds `.zeck` extension for compressed files.\n\n```bash\nzeck-compress [INPUT] [-o OUTPUT] [--endian ENDIAN] [-v]\n```\n\n**Options:**\n- `INPUT`: Input file path (optional, reads from stdin if not specified)\n  - Shows a warning if reading from stdin and no data was piped in\n- `-o, --output FILE`: Output file path (optional)\n  - If not specified and input is a file, uses the input filename with the `.zeck` extension appended\n  - If not specified and reading from stdin, writes to stdout\n  - The `.zeck` extension is automatically added unless the file already ends with `.zeck`\n- `--endian ENDIAN`: Endianness to use (`big`, `little`, or `best`). Default: `best`\n  - `big`: Use big-endian interpretation\n  - `little`: Use little-endian interpretation\n  - `best`: Try both and use the best result (default)\n  - **Note:** When using `best`, if neither method produces compression (both result in larger or equal output), the tool will exit with an error showing compression statistics\n- `-v, --verbose`: Show compression statistics (default: true, use `--no-verbose` to disable)\n\n**Examples:**\n```bash\n# Compress a file (output filename automatically created from input with extension)\nzeck-compress input.bin\n# Creates input.bin.zeck\n\n# Compress with best endianness (statistics shown by default)\nzeck-compress input.bin --endian best\n\n# Compress with specific endianness\nzeck-compress input.bin --endian big\n\n# Compress to a specific output file\nzeck-compress input.bin -o output\n# Creates output.zeck\n\n# Compress from stdin to stdout\ncat input.bin | zeck-compress\n```\n\n**Note:** When writing to a file, the output filename is printed to stdout (e.g., \"Compressed to: input.bin.zeck\"). Verbose statistics are shown by default and include descriptive messages about compression ratios (e.g., \"File was compressed by X.XX% (Y bytes -> Z bytes)\"). A warning is shown when reading from stdin if no data was piped in.\n\n#### zeck-decompress\n\nDecompresses data that was compressed using the Zeckendorf representation algorithm. Automatically detects endianness from the file header.\n\n```bash\nzeck-decompress [INPUT] [-o OUTPUT] [-v]\n```\n\n**Options:**\n- `INPUT`: Input file path (optional, reads from stdin if not specified)\n  - When reading from a file, endianness is automatically detected from the file header\n  - When reading from stdin, endianness is automatically detected from the file header\n  - Shows a warning if reading from stdin and no data was piped in\n- `-o, --output FILE`: Output file path (optional)\n  - If not specified and input is a file, uses the input filename with `.zeck` extension removed\n  - If not specified and reading from stdin, writes to stdout\n- `-v, --verbose`: Show decompression statistics (default: true, use `--no-verbose` to disable)\n\n**Examples:**\n```bash\n# Decompress a file (endianness detected from file header, output filename automatically created)\nzeck-decompress input.zeck\n# Automatically detects endianness from header, creates output file \"input\"\n\n# Decompress to a specific output file\nzeck-decompress input.zeck -o output.bin\n# Automatically detects endianness from header\n\n# Decompress from stdin to stdout\ncat input.zeck | zeck-decompress\n# Automatically detects endianness from header\n```\n\n**Note:** The endianness used for decompression must match the endianness used during compression. The file header stores which endianness was used, so decompression will automatically use the correct endianness when reading from a file or from stdin.\n\n**Additional features:**\n- When writing to a file, the output filename is printed to stdout (e.g., \"Compressed to: input.bin.zeck\" or \"Decompressed to: output.bin\")\n- Verbose statistics are shown by default (use `--no-verbose` to disable) and include descriptive messages about compression/decompression ratios\n- Compression will exit with an error if the data cannot be compressed (when using `--endian best` and neither method produces compression)\n- A warning is shown when reading from stdin if no data was piped in\n\n### Main Playground\n\n```bash\ncargo run --release --example playground\n```\n\nA playground/scratchpad for testing library functions.\n\n### Generate Test Data\n\n```bash\ncargo run --release --bin zeck-generate-data --features development_tools -- <size_in_bytes> [filename]\n```\n\nGenerates random test data files in the `generated_data/` directory.\n\nExample:\n```bash\ncargo run --release --bin zeck-generate-data --features development_tools -- 1024 my_file.bin\n```\n\n### Generate Statistics\n\n```bash\ncargo run --release --example generate-statistics\n```\n\nGenerates comprehensive compression statistics and plots:\n- Compression ratios across different input sizes\n- Chance of compression being favorable\n- Average and median compression ratios\n- Statistics saved to `statistics_history/` directory\n- Plots saved to `plots/` directory\n\n### Plot Compression Ratios\n\n```bash\ncargo run --release --example plot\n```\n\nGenerates visualization plots of:\n- Fibonacci numbers\n- Compression ratios for various input ranges\n\n## Benchmarks\n\n### Zeckendorf Compression Benchmarks\n\n```bash\ncargo bench --bench zeckendorf_bench\n```\n\nBenchmarks compression, decompression, and round-trip performance for various data sizes (4 bytes to 16KB).\n\n### Fibonacci Benchmarks\n\n```bash\ncargo bench --bench fibonacci_bench\n```\n\nCompares performance of different Fibonacci calculation algorithms:\n- Slow iterative method\n- Fast doubling method (~160x faster for large indices)\n\n### Working with Benchmark Baselines\n\nSave a new baseline:\n```bash\ncargo bench --bench zeckendorf_bench -- --save-baseline <name>\n```\n\nCompare to an existing baseline:\n```bash\ncargo bench --bench zeckendorf_bench -- --baseline <name>\n```\n\n## Performance Characteristics\n\n- **Fast Doubling Fibonacci**: ~160x faster than iterative method for the 100,000th Fibonacci number\n- **Memoized Fast Doubling**: Uses sparse HashMap caching for efficient memory usage with large, non-contiguous Fibonacci indices\n- **Memoization**: Thread-safe caching significantly improves repeated calculations. The trade-off is that the cache takes up memory.\n- **Compression Effectiveness**: Varies by input; compression ratios oscillate and become less favorable as input size increases\n\n## Algorithm Details\n\n### Zeckendorf Representation\n\nEvery positive integer can be uniquely represented as a sum of non-consecutive Fibonacci numbers. For example:\n- 12 = 8 + 3 + 1 = F(6) + F(4) + F(2)\n\n### Compression Process\n\n1. Input data is interpreted as either a big-endian or little-endian integer (you can choose, or use `compress_zeck_best` to try both)\n2. The integer is converted to its Zeckendorf representation (list of Fibonacci indices)\n3. The representation is encoded as bits (use/skip bits)\n4. Bits are packed into bytes (little-endian output)\n\nThe library provides functions to compress with either interpretation, or you can use `compress_zeck_best` to automatically try both and select the one that produces the smallest output.\n\n### File Format\n\nThe `.zeck` file format includes a 10-byte header:\n- **Version** (1 byte): File format version (currently 1)\n- **Original Size** (8 bytes): Original uncompressed file size in bytes (little-endian)\n- **Flags** (1 byte): Endianness and reserved flags\n  - Bit 0: Big endian flag (1 = big endian, 0 = little endian)\n  - Bits 1-7: Reserved for future use\n\nThe header is followed by the compressed data. This format automatically preserves the original file size, allowing proper restoration of leading or trailing zero bytes during decompression.\n\n### Effective Fibonacci Indices\n\nThe library uses \"Effective Fibonacci Indices\" (EFI) starting from 0, where:\n- EFI 0 = Fibonacci Index 2 (value 1)\n- EFI 1 = Fibonacci Index 3 (value 2)\n- etc.\n\nThis avoids redundant Fibonacci numbers (F(0)=0 and F(1)=F(2)=1).\n\n## Limitations\n\n- Compression is not guaranteed—some inputs may result in larger output\n- Compression effectiveness decreases as input size increases\n- The library supports both big-endian and little-endian interpretations, but other byte orderings or word boundaries are not currently explored\n- **⚠️ Warning:** Compressing or decompressing files larger than 10KB (10,000 bytes) is unstable due to time and memory pressure. The library may experience performance issues, excessive memory usage, or failures when processing files exceeding this size.\n- Padless compression functions (`*_dangerous`) do not preserve leading/trailing zero bytes—use the file format functions for automatic size preservation\n\n## NPM Versioning Quirk\n\nFor some reason, NPM was showing there were versions of zeck published between `1.0.0` and `1.0.6` from 2024 (we are in 2026), even though I never published them to npm. I don't know how this happened. So I bumped the version to `1.0.7` and was able to successfully publish it to npm. Maybe there was an old package with the same name that was deleted, and NPM is still showing the old versions.\n\nHere is a snippet of the `time` object from the npm registry JSON (https://registry.npmjs.org/zeck):\n\n```json\n  \"time\": {\n    \"created\": \"2026-01-02T20:19:14.018Z\",\n    \"modified\": \"2026-01-03T17:25:15.940Z\",\n    \"1.0.0\": \"2024-02-21T14:36:36.292Z\",\n    \"1.0.1\": \"2024-02-21T15:26:38.621Z\",\n    \"1.0.2\": \"2024-02-21T15:36:30.258Z\",\n    \"1.0.3\": \"2024-02-21T15:48:07.853Z\",\n    \"1.0.4\": \"2024-02-21T15:48:38.804Z\",\n    \"1.0.5\": \"2024-02-21T16:02:36.339Z\",\n    \"1.0.6\": \"2024-02-21T16:36:36.643Z\",\n    \"0.1.0\": \"2026-01-02T20:19:14.175Z\",\n    \"0.2.0\": \"2026-01-03T17:25:15.702Z\"\n  },\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n## References\n\n- [Fast Fibonacci Algorithms](https://www.nayuki.io/page/fast-fibonacci-algorithms) - Fast doubling algorithm reference\n- [Zeckendorf's Theorem](https://en.wikipedia.org/wiki/Zeckendorf%27s_theorem) - Every positive integer has a unique representation as a sum of non-consecutive Fibonacci numbers\n- [Exploring Fibonacci Based Compression](https://medium.com/@peterryszkiewicz/exploring-fibonacci-based-compression-8713770f5598) - My blog post about the Zeckendorf representation algorithm and this library\n","readmeFilename":"README.md"}