[{"data":1,"prerenderedAt":357},["ShallowReactive",2],{"navigation_docs":3,"-formats-deflate":84,"-formats-deflate-surround":352},[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":56,"body":86,"description":345,"extension":346,"links":347,"meta":348,"navigation":349,"path":57,"seo":350,"stem":58,"__hash__":351},"docs\u002F2.formats\u002F01.deflate.md",{"type":87,"value":88,"toc":340},"minimark",[89,92,96,184,187,192,201,204,229,232,251,314,336],[90,91],"format-facts",{"name":56},[93,94,95],"p",{},"The one everybody has. gzip files, zlib streams, PNG images, ZIP entries, HTTP bodies, PDF streams. All of it is deflate inside a different envelope, and here the envelope is an option:",[97,98,103],"pre",{"className":99,"code":100,"language":101,"meta":102,"style":102},"language-ts shiki shiki-themes compressions compressions compressions","compress(\"deflate\", \"hello world!\");                          \u002F\u002F 14 bytes, raw\ncompress(\"deflate\", \"hello world!\", { container: \"zlib\" });   \u002F\u002F 20 bytes, 789c…\ncompress(\"deflate\", \"hello world!\", { container: \"gzip\" });   \u002F\u002F 32 bytes, 1f8b08…\n","ts","",[104,105,106,136,161],"code",{"__ignoreMap":102},[107,108,111,115,119,123,126,129,132],"span",{"class":109,"line":110},"line",1,[107,112,114],{"class":113},"sK71F","compress",[107,116,118],{"class":117},"s38Sx","(",[107,120,122],{"class":121},"shU9J","\"deflate\"",[107,124,125],{"class":117},", ",[107,127,128],{"class":121},"\"hello world!\"",[107,130,131],{"class":117},");                          ",[107,133,135],{"class":134},"scIB-","\u002F\u002F 14 bytes, raw\n",[107,137,139,141,143,145,147,149,152,155,158],{"class":109,"line":138},2,[107,140,114],{"class":113},[107,142,118],{"class":117},[107,144,122],{"class":121},[107,146,125],{"class":117},[107,148,128],{"class":121},[107,150,151],{"class":117},", { container: ",[107,153,154],{"class":121},"\"zlib\"",[107,156,157],{"class":117}," });   ",[107,159,160],{"class":134},"\u002F\u002F 20 bytes, 789c…\n",[107,162,164,166,168,170,172,174,176,179,181],{"class":109,"line":163},3,[107,165,114],{"class":113},[107,167,118],{"class":117},[107,169,122],{"class":121},[107,171,125],{"class":117},[107,173,128],{"class":121},[107,175,151],{"class":117},[107,177,178],{"class":121},"\"gzip\"",[107,180,157],{"class":117},[107,182,183],{"class":134},"\u002F\u002F 32 bytes, 1f8b08…\n",[93,185,186],{},"The writer is LZ77 with lazy matching, the way zlib does it, and picks fixed, dynamic or stored blocks by whichever comes out smaller. On text it lands at zlib's size or under.",[188,189,191],"h2",{"id":190},"levels","Levels",[93,193,194,197,198,200],{},[104,195,196],{},"level"," goes from 0 to 9, 6 by default. 0 stores: no compression, just the bytes in blocks of up to 64 KiB, so ",[104,199,128],{}," comes out as 17 bytes with the text sitting in plain sight. 1 is fastest, 9 searches longest. The gaps are small on short input and grow with it.",[188,202,203],{"id":203},"zlib",[93,205,206,207,210,211,125,214,125,217,220,221,224,225,228],{},"Two header bytes, raw deflate, then the Adler-32 of the output. The header names the level the writer used, which comes back in ",[104,208,209],{},"details.level"," as ",[104,212,213],{},"fastest",[104,215,216],{},"fast",[104,218,219],{},"default"," or ",[104,222,223],{},"best",". A zlib stream that asks for a preset dictionary is an ",[104,226,227],{},"UnsupportedError",", since nobody hands one over.",[188,230,231],{"id":231},"gzip",[93,233,234,235,238,239,242,243,246,247,250],{},"Ten header bytes starting ",[104,236,237],{},"1f 8b 08",", raw deflate, then a CRC-32 and the size. ",[104,240,241],{},"name"," and ",[104,244,245],{},"mtime"," go in the header when you set them, and come back in ",[104,248,249],{},"details",":",[97,252,254],{"className":99,"code":253,"language":101,"meta":102,"style":102},"const gz = compress(\"deflate\", \"hello world!\", { container: \"gzip\", name: \"notes.txt\", mtime: 1700000000 });\ndecompress(\"deflate\", gz, { container: \"gzip\" }).details;\n\u002F\u002F { name: \"notes.txt\", mtime: 1700000000, os: 255, members: 1 }\n",[104,255,256,292,309],{"__ignoreMap":102},[107,257,258,262,265,268,271,273,275,277,279,281,283,286,289],{"class":109,"line":110},[107,259,261],{"class":260},"skH_V","const",[107,263,264],{"class":117}," gz ",[107,266,267],{"class":260},"=",[107,269,270],{"class":113}," compress",[107,272,118],{"class":117},[107,274,122],{"class":121},[107,276,125],{"class":117},[107,278,128],{"class":121},[107,280,151],{"class":117},[107,282,178],{"class":121},[107,284,285],{"class":117},", name: ",[107,287,288],{"class":121},"\"notes.txt\"",[107,290,291],{"class":117},", mtime: 1700000000 });\n",[107,293,294,297,299,301,304,306],{"class":109,"line":138},[107,295,296],{"class":113},"decompress",[107,298,118],{"class":117},[107,300,122],{"class":121},[107,302,303],{"class":117},", gz, { container: ",[107,305,178],{"class":121},[107,307,308],{"class":117}," }).details;\n",[107,310,311],{"class":109,"line":163},[107,312,313],{"class":134},"\u002F\u002F { name: \"notes.txt\", mtime: 1700000000, os: 255, members: 1 }\n",[93,315,316,319,320,323,324,327,328,331,332,335],{},[104,317,318],{},"os"," is 255, unknown, because this package doesn't know what machine you're on and isn't going to guess. Several members in a row decompress into one output, the way ",[104,321,322],{},"gunzip"," reads ",[104,325,326],{},"cat a.gz b.gz",", and ",[104,329,330],{},"details.members"," counts them. Zeros after the last member are tape padding and get skipped. Anything else after it is reported as ",[104,333,334],{},"trailing",".",[337,338,339],"style",{},"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 .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 .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);}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)}",{"title":102,"searchDepth":138,"depth":138,"links":341},[342,343,344],{"id":190,"depth":138,"text":191},{"id":203,"depth":138,"text":203},{"id":231,"depth":138,"text":231},"LZ77 with Huffman codes behind gzip and zlib and PNG and ZIP. Raw or zlib or gzip and one level from 0 to 9","md",null,{},true,{"title":56,"description":345},"IwR8RfhFneSIq8nYnXvJeO0W3u8acUlf8GOR69p7UEE",[353,355],{"title":54,"path":50,"stem":51,"description":354,"children":-1},"Every format the package ships with its containers and checksums and options. Read live from the registry",{"title":60,"path":61,"stem":62,"description":356,"children":-1},"Burrows-Wheeler transform then move-to-front then Huffman. Slow and small on text with a CRC on every block",1791071141269]