{"id":27363684,"url":"https://github.com/micheal-ndoh/compression_project","last_synced_at":"2026-04-30T07:41:40.047Z","repository":{"id":287368855,"uuid":"964497721","full_name":"micheal-ndoh/compression_project","owner":"micheal-ndoh","description":"A compression project that uses lz and rle techniques for compression, https://www.geeksforgeeks.org/what-are-data-compression-techniques/","archived":false,"fork":false,"pushed_at":"2025-04-22T21:27:04.000Z","size":103,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T21:33:45.483Z","etag":null,"topics":["compression-algorithm","javascript","lz-compression-algorithm","rle-compression-algorithm","rust"],"latest_commit_sha":null,"homepage":"https://dev.to/binoy123/data-compression-part-1-lossless-compression-3o83","language":"JavaScript","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/micheal-ndoh.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,"zenodo":null}},"created_at":"2025-04-11T09:59:56.000Z","updated_at":"2025-04-22T21:27:07.000Z","dependencies_parsed_at":"2025-04-11T12:03:39.577Z","dependency_job_id":"42efe571-afca-43c5-8dce-f6f03c53352a","html_url":"https://github.com/micheal-ndoh/compression_project","commit_stats":null,"previous_names":["micheal-ndoh/compression_project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/micheal-ndoh/compression_project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheal-ndoh%2Fcompression_project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheal-ndoh%2Fcompression_project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheal-ndoh%2Fcompression_project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheal-ndoh%2Fcompression_project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micheal-ndoh","download_url":"https://codeload.github.com/micheal-ndoh/compression_project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheal-ndoh%2Fcompression_project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259786303,"owners_count":22910914,"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","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":["compression-algorithm","javascript","lz-compression-algorithm","rle-compression-algorithm","rust"],"created_at":"2025-04-13T04:33:28.920Z","updated_at":"2026-04-30T07:41:35.021Z","avatar_url":"https://github.com/micheal-ndoh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File Compression CLI\n\nA command-line tool that implements and compares different compression algorithms in JavaScript and Rust.\n\n## Supported Algorithms\n\n- RLE (Run-Length Encoding): Best for files with lots of repeated characters\n- LZ77 (Lempel-Ziv 77): Better for general-purpose compression\n\n## Prerequisites\n\n- Docker\n- Node.js (for WASM and local usage)\n- Rust (for local usage)\n\n## Usage Instructions\n\n### 1. Using JavaScript Implementation\n\n#### Compression\n\n```bash\n# RLE Compression\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest compress \"/data/input.txt\" \"/data/output.compressed\" --algorithm rle\n```\n\n```bash\n# LZ77 Compression\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest compress \"/data/input.txt\" \"/data/output.compressed\" --algorithm lz77\n```\n\n```bash\n# Auto-detect algorithm based on file type\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest compress \"/data/input.txt\" \"/data/output.compressed\" --algorithm auto\n```\n\n#### Decompression\n\n```bash\n# RLE Decompression\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest decompress \"/data/input.compressed\" \"/data/output.txt\" --algorithm rle\n```\n\n```bash\n# LZ77 Decompression\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest decompress \"/data/input.compressed\" \"/data/output.txt\" --algorithm lz77\n```\n\n### 2. Using Rust Implementation\n\n#### Compression\n\n```bash\n# RLE Compression\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/rust-compressor:latest compress \"/data/input.txt\" \"/data/output.compressed\" --algorithm rle\n```\n\n```bash\n# LZ77 Compression\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/rust-compressor:latest compress \"/data/input.txt\" \"/data/output.compressed\" --algorithm lz77\n```\n\n```bash\n# Auto-detect algorithm\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/rust-compressor:latest compress \"/data/input.txt\" \"/data/output.compressed\" --algorithm auto\n```\n\n#### Decompression\n\n```bash\n# RLE Decompression\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/rust-compressor:latest decompress \"/data/input.compressed\" \"/data/output.txt\" --algorithm rle\n```\n\n```bash\n# LZ77 Decompression\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/rust-compressor:latest decompress \"/data/input.compressed\" \"/data/output.txt\" --algorithm lz77\n```\n\n### 3. Benchmark Tool\n\nTo compare all implementations and algorithms at once:\n\n```bash\n./benchmark.sh input.txt\n```\n\nThis will:\n\n- Test both RLE and LZ77 algorithms\n- Compare JavaScript and Rust implementations\n- Generate a report with:\n  - Compression ratios\n  - Compression/decompression speeds\n  - File size comparisons\n  - Verification results\n\n## Advanced Features\n\n### 1. Stdin/Stdout Streaming\n\nBoth implementations support reading from stdin and writing to stdout using `-` as the file path:\n\n```bash\n# JavaScript Implementation\n# Compress from stdin to stdout\necho \"Hello World\" | docker run --rm -i ghcr.io/micheal-ndoh/js-compressor:latest compress - - --algorithm rle \u003e output.compressed\n```\n\n```bash\n# Decompress from stdin to stdout\ncat output.compressed | docker run --rm -i ghcr.io/micheal-ndoh/js-compressor:latest decompress - - --algorithm rle \u003e output.txt\n```\n\n```bash\n# Rust Implementation\n# Compress from stdin to stdout\necho \"Hello World\" | docker run --rm -i ghcr.io/micheal-ndoh/rust-compressor:latest compress - - --algorithm rle \u003e output.compressed\n```\n\n```bash\n# Decompress from stdin to stdout\ncat output.compressed | docker run --rm -i ghcr.io/micheal-ndoh/rust-compressor:latest decompress - - --algorithm rle \u003e output.txt\n```\n\n### 2. Automatic Algorithm Selection\n\nBoth implementations can automatically choose the best compression algorithm based on file content:\n\n```bash\n# JavaScript Implementation\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest compress \"/data/input.txt\" \"/data/output.compressed\" --algorithm auto\n\n# Rust Implementation\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/rust-compressor:latest compress \"/data/input.txt\" \"/data/output.compressed\" --algorithm auto\n```\n\n### 3. WebAssembly (WASM) Support\n\nUse the Rust implementation directly in JavaScript through WebAssembly:\n\n```javascript\n// In your JavaScript code\nimport init, { compress_rle, decompress_rle, compress_lz77, decompress_lz77 } from '@micheal-ndoh/rust-compressor-wasm';\n\nasync function example() {\n    // Initialize WASM module\n    await init();\n\n    // Compress using RLE\n    const input = new TextEncoder().encode('Hello World');\n    const compressed = compress_rle(input);\n    \n    // Decompress\n    const decompressed = decompress_rle(compressed);\n    console.log(new TextDecoder().decode(decompressed));\n}\n```\n\n### 4. Multiple File Compression\n\nCompress multiple files in a single command using glob patterns:\n\n```bash\n# JavaScript Implementation\n# Compress all text files in current directory\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest compress \"/data/*.txt\" \"/data/output/\" --algorithm auto\n\n# Rust Implementation\n# Compress all text files in current directory\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/rust-compressor:latest compress \"/data/*.txt\" \"/data/output/\" --algorithm auto\n\n# Decompress multiple files\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest decompress \"/data/output/*.compressed\" \"/data/restored/\" --algorithm auto\n```\n\n## Command Format\n\n```bash\ndocker run --rm -v \"$(pwd):/data\" [IMAGE] [COMMAND] [INPUT] [OUTPUT] --algorithm [ALGORITHM]\n\nWhere:\n- IMAGE: ghcr.io/micheal-ndoh/js-compressor:latest or ghcr.io/micheal-ndoh/rust-compressor:latest\n- COMMAND: compress or decompress\n- INPUT: path to input file/pattern (prefix with /data/) or - for stdin\n- OUTPUT: path to output file/directory (prefix with /data/) or - for stdout\n- ALGORITHM: rle, lz77, or auto\n```\n\n## Examples\n\n1. Compress a text file using JavaScript RLE:\n\n```bash\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest compress \"/data/myfile.txt\" \"/data/myfile.compressed\" --algorithm rle\n```\n\n2. Decompress using Rust LZ77:\n\n```bash\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/rust-compressor:latest decompress \"/data/myfile.compressed\" \"/data/myfile.restored\" --algorithm lz77\n```\n\n3. Run benchmark on a specific file:\n\n```bash\n./benchmark.sh myfile.txt\n```\n\n4. Compress multiple files with auto-detection:\n\n```bash\ndocker run --rm -v \"$(pwd):/data\" ghcr.io/micheal-ndoh/js-compressor:latest compress \"/data/files/*.txt\" \"/data/compressed/\" --algorithm auto\n```\n\n5. Stream compression through pipes:\n\n```bash\ncat myfile.txt | docker run --rm -i ghcr.io/micheal-ndoh/rust-compressor:latest compress - - --algorithm rle \u003e compressed.bin\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicheal-ndoh%2Fcompression_project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicheal-ndoh%2Fcompression_project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicheal-ndoh%2Fcompression_project/lists"}