{"id":32704652,"url":"https://github.com/jedisct1/zig-lz4","last_synced_at":"2026-07-01T04:31:37.763Z","repository":{"id":321494619,"uuid":"1086066737","full_name":"jedisct1/zig-lz4","owner":"jedisct1","description":"LZ4 implementation in pure Zig.","archived":false,"fork":false,"pushed_at":"2026-06-12T09:04:54.000Z","size":146,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-19T18:38:36.811Z","etag":null,"topics":["library","lz4","lz4f","lz4hc","zig","zig-package","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jedisct1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-10-29T22:39:58.000Z","updated_at":"2026-06-12T09:04:53.000Z","dependencies_parsed_at":"2025-10-30T00:28:24.025Z","dependency_job_id":"b72b61a3-7f2e-4a69-bd66-71468e5e93e4","html_url":"https://github.com/jedisct1/zig-lz4","commit_stats":null,"previous_names":["jedisct1/zig-lz4"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jedisct1/zig-lz4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fzig-lz4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fzig-lz4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fzig-lz4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fzig-lz4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jedisct1","download_url":"https://codeload.github.com/jedisct1/zig-lz4/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fzig-lz4/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34993435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["library","lz4","lz4f","lz4hc","zig","zig-package","ziglang"],"created_at":"2025-11-02T01:01:21.890Z","updated_at":"2026-07-01T04:31:37.750Z","avatar_url":"https://github.com/jedisct1.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-lz4\n\nA pure Zig implementation of LZ4 compression. This is a complete port of the C reference implementation by Yann Collet, rewritten in safe Zig.\n\n## What is LZ4?\n\nLZ4 is a fast lossless compression algorithm focused on speed. It's widely used in systems where you need compression but can't afford the CPU overhead of heavier algorithms like gzip or zstd.\n\n## Features\n\nThis library implements the full LZ4 spec:\n\n- Block compression - The basic LZ4 algorithm for compressing individual blocks\n- HC mode - High compression variant that trades speed for better compression ratios\n- Frame format - The standard LZ4 frame format with checksums and metadata\n- Streaming - Compress and decompress data incrementally\n- Dictionaries - Use external dictionaries for better compression of small blocks\n\nAll code is pure Zig with no C dependencies. The implementation follows the same algorithms as the reference C library and passes compatibility tests with the standard `lz4` tool.\n\n## Requirements\n\n- Zig 0.16.0 or newer\n\n## Usage\n\nAdd it to your `build.zig.zon`:\n\n```zig\n.dependencies = .{\n    .lz4 = .{\n        .url = \"https://github.com/jedisct1/zig-lz4/archive/\u003ccommit\u003e.tar.gz\",\n        .hash = \"...\",\n    },\n},\n```\n\nThen in your `build.zig`:\n\n```zig\nconst lz4 = b.dependency(\"lz4\", .{\n    .target = target,\n    .optimize = optimize,\n});\nexe.root_module.addImport(\"lz4\", lz4.module(\"lz4\"));\n```\n\n### Basic compression\n\n```zig\nconst lz4 = @import(\"lz4\");\nconst std = @import(\"std\");\n\npub fn main() !void {\n    const allocator = std.heap.smp_allocator;\n\n    const input = \"Hello, World!\";\n\n    // Allocate buffer for compressed data\n    const max_size = lz4.compressBound(input.len);\n    const compressed = try allocator.alloc(u8, max_size);\n    defer allocator.free(compressed);\n\n    // Compress\n    const compressed_size = try lz4.compressDefault(input, compressed);\n\n    // Decompress\n    const decompressed = try allocator.alloc(u8, input.len);\n    defer allocator.free(decompressed);\n\n    _ = try lz4.decompressSafe(compressed[0..compressed_size], decompressed);\n}\n```\n\n### HC (high compression) mode\n\n```zig\nconst lz4 = @import(\"lz4\");\n\n// Use higher compression level (2-12)\nconst compressed_size = try lz4.compressHC(\n    input,\n    compressed,\n    lz4.LZ4HC_CLEVEL_DEFAULT, // level 9\n);\n```\n\n### Frame format\n\nThe frame format adds checksums and is what the `lz4` command-line tool uses:\n\n```zig\nconst lz4 = @import(\"lz4\");\n\n// Compress a whole frame in one shot\nconst bound = lz4.lz4f.compressFrameBound(input.len, null);\nconst frame = try allocator.alloc(u8, bound);\ndefer allocator.free(frame);\n\nconst frame_size = try lz4.lz4f.compressFrame(allocator, input, frame, null);\n\n// Decompress it back\nconst decompressed = try allocator.alloc(u8, input.len);\ndefer allocator.free(decompressed);\n\nconst size = try lz4.lz4f.decompressFrame(allocator, frame[0..frame_size], decompressed);\n```\n\nPass a `lz4.lz4f.Preferences` value instead of `null` to pick the block size,\nenable checksums, or use an HC compression level.\n\n## Building and testing\n\n```bash\n# Run tests\nzig build test\n\n# Run specific test suites\nzig build test-lz4hc\nzig build test-lz4f\nzig build test-compat\n\n# Build the library\nzig build\n```\n\nThe test suite includes compatibility tests against the reference `lz4` tool: frames produced by this library are decompressed with `lz4`, and vice versa, at every compression level. The `test-compat` step needs the `lz4` command-line tool installed.\n\n## Compatibility\n\nThis implementation is designed to be wire-compatible with the reference LZ4 library. Files compressed with this library can be decompressed by the standard `lz4` tool and vice versa.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedisct1%2Fzig-lz4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjedisct1%2Fzig-lz4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedisct1%2Fzig-lz4/lists"}