[{"data":1,"prerenderedAt":431},["ShallowReactive",2],{"navigation_docs":3,"-guide":84,"-guide-surround":428},[4,48],{"title":5,"path":6,"stem":7,"children":8,"icon":47},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19,23,27,31,35,39,43],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Compressing","\u002Fguide\u002Fcompressing","1.guide\u002F02.compressing",{"title":16,"path":17,"stem":18},"Containers","\u002Fguide\u002Fcontainers","1.guide\u002F03.containers",{"title":20,"path":21,"stem":22},"Checksums","\u002Fguide\u002Fchecksums","1.guide\u002F04.checksums",{"title":24,"path":25,"stem":26},"Identify and peel","\u002Fguide\u002Fidentify","1.guide\u002F05.identify",{"title":28,"path":29,"stem":30},"Limits","\u002Fguide\u002Flimits","1.guide\u002F06.limits",{"title":32,"path":33,"stem":34},"CLI","\u002Fguide\u002Fcli","1.guide\u002F07.cli",{"title":36,"path":37,"stem":38},"Agents","\u002Fguide\u002Fagents","1.guide\u002F08.agents",{"title":40,"path":41,"stem":42},"Custom formats","\u002Fguide\u002Fcustom","1.guide\u002F09.custom",{"title":44,"path":45,"stem":46},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F10.playground","i-lucide-book-open",{"title":49,"path":50,"stem":51,"children":52,"icon":83},"Formats","\u002Fformats","2.formats\u002F00.index",[53,55,59,63,67,71,75,79],{"title":54,"path":50,"stem":51},"Every format",{"title":56,"path":57,"stem":58},"deflate","\u002Fformats\u002Fdeflate","2.formats\u002F01.deflate",{"title":60,"path":61,"stem":62},"bzip2","\u002Fformats\u002Fbzip2","2.formats\u002F02.bzip2",{"title":64,"path":65,"stem":66},"LZMA","\u002Fformats\u002Flzma","2.formats\u002F03.lzma",{"title":68,"path":69,"stem":70},"Zstandard","\u002Fformats\u002Fzstd","2.formats\u002F04.zstd",{"title":72,"path":73,"stem":74},"Brotli","\u002Fformats\u002Fbrotli","2.formats\u002F05.brotli",{"title":76,"path":77,"stem":78},"LZ4","\u002Fformats\u002Flz4","2.formats\u002F06.lz4",{"title":80,"path":81,"stem":82},"Unix compress","\u002Fformats\u002Flzw","2.formats\u002F07.lzw","i-lucide-library",{"id":85,"title":10,"body":86,"description":422,"extension":423,"links":424,"meta":425,"navigation":212,"path":6,"seo":426,"stem":7,"__hash__":427},"docs\u002F1.guide\u002F01.index.md",{"type":87,"value":88,"toc":416},"minimark",[89,94,99,104,113,120,141,145,170,177,181,339,358,364,368,412],[90,91,93],"warning",{"title":92},"Pre-1.0","The API and the tool list can still move. Pin exact versions if you build on it now.",[95,96,98],"caution",{"title":97},"Not audited","This code has never had a security audit. Do not use it in production, with real funds or with sensitive data, and don't point it at untrusted bytes at scale. It is meant for agents, puzzles, CTFs and local experiments. It comes as is, without warranty of any kind, and the authors are not liable for any loss, as the MIT license states. Anything that matters wants an audited library.",[100,101,103],"h2",{"id":102},"why-this-exists","Why this exists",[105,106,107,108,112],"p",{},"Hand a model a blob that starts with ",[109,110,111],"code",{},"1f 8b"," and ask what's inside. It knows that's gzip. It will even describe gzip to you, beautifully. What it can't do is run Huffman decoding in its head, so it guesses the contents. Confidently.",[105,114,115,116,119],{},"So the model should call something that actually decompresses. ",[109,117,118],{},"@agntn\u002Fcompressions"," is that something. Same thing in your TypeScript, your terminal and your agent.",[105,121,122,123,132,133,140],{},"Every format here is written from its spec. RFC 1950, 1951 and 1952 for zlib, deflate and gzip. RFC 8878 for zstd, RFC 7932 for brotli. The xz file format, the LZMA spec, the LZ4 frame format, bzip2 and Unix compress after their reference code. No zlib binding, no liblzma, no WASM. The checksums come from ",[124,125,129],"a",{"href":126,"rel":127},"https:\u002F\u002Fhashes.agntn.dev",[128],"nofollow",[109,130,131],{},"@agntn\u002Fhashes",", base64 and hex for the tools from ",[124,134,137],{"href":135,"rel":136},"https:\u002F\u002Fencodings.agntn.dev",[128],[109,138,139],{},"@agntn\u002Fencodings",".",[100,142,144],{"id":143},"install","Install",[146,147,152],"pre",{"className":148,"code":149,"language":150,"meta":151,"style":151},"language-bash shiki shiki-themes compressions compressions compressions","pnpm add @agntn\u002Fcompressions\n","bash","",[109,153,154],{"__ignoreMap":151},[155,156,159,163,167],"span",{"class":157,"line":158},"line",1,[155,160,162],{"class":161},"sK71F","pnpm",[155,164,166],{"class":165},"shU9J"," add",[155,168,169],{"class":165}," @agntn\u002Fcompressions\n",[105,171,172,173,176],{},"Node.js 26 or newer. The library itself touches nothing from ",[109,174,175],{},"node:*",", which is why this site runs it in your browser.",[100,178,180],{"id":179},"first-calls","First calls",[146,182,186],{"className":183,"code":184,"language":185,"meta":151,"style":151},"language-ts shiki shiki-themes compressions compressions compressions","import { compress, decompress, identify } from \"@agntn\u002Fcompressions\";\n\nconst gz = compress(\"deflate\", \"hello world!\", { container: \"gzip\" });\n\u002F\u002F Uint8Array(32), starting 1f 8b 08\n\nnew TextDecoder().decode(decompress(\"deflate\", gz, { container: \"gzip\" }).bytes);\n\u002F\u002F \"hello world!\"\n\nidentify(compress(\"lzma\", \"hello world!\", { container: \"xz\" }))[0];\n\u002F\u002F { format: \"lzma\", container: \"xz\", confidence: 100, confirmed: true, … }\n","ts",[109,187,188,207,214,250,257,262,294,300,305,333],{"__ignoreMap":151},[155,189,190,194,198,201,204],{"class":157,"line":158},[155,191,193],{"class":192},"skH_V","import",[155,195,197],{"class":196},"s38Sx"," { compress, decompress, identify } ",[155,199,200],{"class":192},"from",[155,202,203],{"class":165}," \"@agntn\u002Fcompressions\"",[155,205,206],{"class":196},";\n",[155,208,210],{"class":157,"line":209},2,[155,211,213],{"emptyLinePlaceholder":212},true,"\n",[155,215,217,220,223,226,229,232,235,238,241,244,247],{"class":157,"line":216},3,[155,218,219],{"class":192},"const",[155,221,222],{"class":196}," gz ",[155,224,225],{"class":192},"=",[155,227,228],{"class":161}," compress",[155,230,231],{"class":196},"(",[155,233,234],{"class":165},"\"deflate\"",[155,236,237],{"class":196},", ",[155,239,240],{"class":165},"\"hello world!\"",[155,242,243],{"class":196},", { container: ",[155,245,246],{"class":165},"\"gzip\"",[155,248,249],{"class":196}," });\n",[155,251,253],{"class":157,"line":252},4,[155,254,256],{"class":255},"scIB-","\u002F\u002F Uint8Array(32), starting 1f 8b 08\n",[155,258,260],{"class":157,"line":259},5,[155,261,213],{"emptyLinePlaceholder":212},[155,263,265,268,271,274,277,279,282,284,286,289,291],{"class":157,"line":264},6,[155,266,267],{"class":192},"new",[155,269,270],{"class":161}," TextDecoder",[155,272,273],{"class":196},"().",[155,275,276],{"class":161},"decode",[155,278,231],{"class":196},[155,280,281],{"class":161},"decompress",[155,283,231],{"class":196},[155,285,234],{"class":165},[155,287,288],{"class":196},", gz, { container: ",[155,290,246],{"class":165},[155,292,293],{"class":196}," }).bytes);\n",[155,295,297],{"class":157,"line":296},7,[155,298,299],{"class":255},"\u002F\u002F \"hello world!\"\n",[155,301,303],{"class":157,"line":302},8,[155,304,213],{"emptyLinePlaceholder":212},[155,306,308,311,313,316,318,321,323,325,327,330],{"class":157,"line":307},9,[155,309,310],{"class":161},"identify",[155,312,231],{"class":196},[155,314,315],{"class":161},"compress",[155,317,231],{"class":196},[155,319,320],{"class":165},"\"lzma\"",[155,322,237],{"class":196},[155,324,240],{"class":165},[155,326,243],{"class":196},[155,328,329],{"class":165},"\"xz\"",[155,331,332],{"class":196}," }))[0];\n",[155,334,336],{"class":157,"line":335},10,[155,337,338],{"class":255},"\u002F\u002F { format: \"lzma\", container: \"xz\", confidence: 100, confirmed: true, … }\n",[105,340,341,343,344,347,348,350,351,354,355,357],{},[109,342,315],{}," takes a string, read as UTF-8, or a ",[109,345,346],{},"Uint8Array",", and gives bytes back. ",[109,349,281],{}," gives bytes back plus ",[109,352,353],{},"details"," for whatever the stream carried: a gzip file name, the check xz used, how many bytes followed the stream. Don't know the format? ",[109,356,310],{}," tries every container whose start fits and shows its reasoning.",[105,359,360,361,363],{},"gzip isn't a format of its own here, it's deflate in a gzip container. Same for zlib and raw deflate, and xz and .lzma are both LZMA. ",[124,362,16],{"href":17}," explains why that's one option instead of five names.",[100,365,367],{"id":366},"pick-your-door","Pick your door",[369,370,371,378,383,388,393,399,407],"ul",{},[372,373,374,377],"li",{},[124,375,376],{"href":13},"Compressing and decompressing"," for the two calls, the format objects and the subpaths.",[372,379,380,382],{},[124,381,16],{"href":17}," for gzip, zlib, xz and the lz4 frames, and what each one wraps.",[372,384,385,387],{},[124,386,20],{"href":21}," for CRC-32, Adler-32, CRC-64, XXH32 and XXH64, and what happens when one doesn't match.",[372,389,390,392],{},[124,391,24],{"href":25}," for the mystery blob somebody just sent you.",[372,394,395,398],{},[124,396,397],{"href":29},"Limits and partial reads"," for bombs, truncated downloads and broken streams.",[372,400,401,403,404,406],{},[124,402,32],{"href":33}," and ",[124,405,36],{"href":37}," for the terminal and for MCP, Pi, OMP and the AI SDK.",[372,408,409,411],{},[124,410,54],{"href":50}," for the whole registry, sortable.",[413,414,415],"style",{},"html pre.shiki code .skH_V, html code.shiki .skH_V{--shiki-light:var(--shiki-token-keyword);--shiki-default:var(--shiki-token-keyword);--shiki-dark:var(--shiki-token-keyword)}html pre.shiki code .s38Sx, html code.shiki .s38Sx{--shiki-light:var(--ui-text-highlighted);--shiki-default:var(--ui-text-highlighted);--shiki-dark:var(--ui-text-highlighted)}html pre.shiki code .shU9J, html code.shiki .shU9J{--shiki-light:var(--shiki-token-string);--shiki-default:var(--shiki-token-string);--shiki-dark:var(--shiki-token-string)}html pre.shiki code .sK71F, html code.shiki .sK71F{--shiki-light:var(--shiki-token-function);--shiki-default:var(--shiki-token-function);--shiki-dark:var(--shiki-token-function)}html pre.shiki code .scIB-, html code.shiki .scIB-{--shiki-light:var(--shiki-token-comment);--shiki-default:var(--shiki-token-comment);--shiki-dark:var(--shiki-token-comment)}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":151,"searchDepth":209,"depth":209,"links":417},[418,419,420,421],{"id":102,"depth":209,"text":103},{"id":143,"depth":209,"text":144},{"id":179,"depth":209,"text":180},{"id":366,"depth":209,"text":367},"Install the package and open your first gzip file. Every format answers the same two calls","md",null,{"icon":47},{"title":10,"description":422},"jljZrt7v-38Lo-FIWgIeexbEhAydkej1U74RduoacqI",[424,429],{"title":12,"path":13,"stem":14,"description":430,"children":-1},"Two calls for every format. Options and levels and the format objects and one subpath per format",1791071141269]