{"id":16641802,"url":"https://github.com/samthor/but-unzip","last_synced_at":"2025-03-21T15:32:23.307Z","repository":{"id":57191854,"uuid":"466614111","full_name":"samthor/but-unzip","owner":"samthor","description":"small ~1k unzip library","archived":false,"fork":false,"pushed_at":"2024-01-26T00:08:56.000Z","size":123,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-13T16:31:17.845Z","etag":null,"topics":["nodejs","unzip","zip"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/but-unzip","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samthor.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}},"created_at":"2022-03-06T02:12:22.000Z","updated_at":"2025-01-31T14:35:35.000Z","dependencies_parsed_at":"2024-10-31T23:45:45.138Z","dependency_job_id":null,"html_url":"https://github.com/samthor/but-unzip","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fbut-unzip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fbut-unzip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fbut-unzip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fbut-unzip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samthor","download_url":"https://codeload.github.com/samthor/but-unzip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244822734,"owners_count":20516156,"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":["nodejs","unzip","zip"],"created_at":"2024-10-12T07:47:55.305Z","updated_at":"2025-03-21T15:32:23.003Z","avatar_url":"https://github.com/samthor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# but-unzip\n\nsmall unzip library.\n~743 bytes for Node,\nand ~999^ bytes for browsers.\n\n^90%+ of browsers support [the decompression API](https://caniuse.com/mdn-api_decompressionstream).\nFor the last 10%, dynamically import `pako`, adding ~20k.\n\n## Usage\n\nInstall via your favorite package manager and import `but-unzip`.\nHas zero dependencies.\n\n```bash\n$ npm install but-unzip\n\n# for old browsers you need\n$ npm install pako\n```\n\nThis library returns zip entries synchronously, but only returns an entry's uncompressed bytes after calling `.read()`, which'll give `Uint8Array` _or_ `Promise\u003cUint8Array\u003e`.\n\n### Naïve use\n\nIf there's a built-in function to inflate compressed files (like in Node or 90%+ of browsers), you can use the code like:\n\n```js\nimport { iter } from 'but-unzip';\nimport * as fs from 'fs';\n\nconst bytes = fs.readFileSync('somezip.zip');\n\nfor (const entry of iter(bytes)) {\n  console.info(entry.name, entry.comment);\n  const bytes = await entry.read();\n  // do something with bytes\n}\n```\n\n### Provide inflate function\n\nIf you're worried about maximum compatibility:\n\n```js\nimport { unzip, inflateRaw as platformInflateRaw } from 'but-unzip';\nimport { inflateRaw as pakoInflateRaw } from 'pako/lib/inflate.js';\n\nasync function decompressUint8Array(zipBytes) {\n  const allEntries = unzip(zipBytes, platformInflateRaw || pakoInflateRaw);\n  // do something with entries\n}\n```\n\n### Dynamically import inflate\n\nYou should only fetch `pako` if you need to, because again, 90% of people don't need it:\n\n```js\nimport { unzip, inflateRaw as platformInflateRaw } from 'but-unzip';\n\nconst inflateRaw = platformInflateRaw || (await import('pako/lib/inflate.js').inflateRaw);\n\n// later\nconst all = unzip(zipBytes, inflateRaw);\n```\n\n## Limitations\n\n* This library doesn't support ZIP64, but probably should.\n  But your browser (and Node) will probably not be happy to work with 4gb+ files, especially as this is not a streaming library (it just gives everything at once).\n\n* Like literally every zip library that exists, this only supports compression types 0 (store) and 8 (deflate).\n\n## Notes\n\n* Pako's ESM bundling can be a bit broken, so importing 'pako/lib/inflate.js' adds ~20k.\n  Importing 'pako' wholesale, even if you only use `inflateRaw`, adds ~45k.\n\n* The main thread is only good for decompressing small things.\n  If you're handling user data and it could be really big, use a `Worker`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamthor%2Fbut-unzip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamthor%2Fbut-unzip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamthor%2Fbut-unzip/lists"}