unzipit.js is a JavaScript library providing efficient, random-access decompression of ZIP archives in both browser and Node.js environments. Currently stable at version 2.0.1, it offers significant performance advantages, claiming 6x to 25x faster extraction speeds than alternatives like JSZip, coupled with considerably lower memory consumption. A key differentiating feature is its ability to perform partial downloads of ZIP files by leveraging HTTP range requests, allowing selective extraction without fetching the entire archive. The library supports parallel processing through web workers, further enhancing speed. It accepts various input types, including URLs, Blobs, ArrayBuffers, and custom `Reader` implementations, making it versatile for diverse use cases. While designed for ESM, it also provides a CommonJS entry point for Node.js projects, with recent versions (Node >=18) primarily favoring ES Modules.
npm install unzipitVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of `unzipit` to fetch a ZIP file from a URL, list its contents, and extract specific entries as text and Blob objects, handling potential errors.
Replace `const unzipit = require('unzipit')` with `import { unzip } from 'unzipit'` or `import * as unzipit from 'unzipit'` for ES Module compatibility. Ensure your project's `package.json` specifies `"type": "module"` or uses `.mjs` file extensions for ESM.Call `setOptions({workerURL: 'path/to/unzipit-worker.module.js'})` *before* calling `unzip`. The worker script is usually found in the `dist` folder of the `unzipit` package.For Node.js, first read the file into a buffer using `fsPromises.readFile()` or use a library like `node-fetch` to get a `Blob` or `ArrayBuffer` from a URL, then pass that data to `unzip`.
Use `Object.entries(entries)`, `Object.keys(entries)`, or `Object.values(entries)` to iterate over the entries, as shown in the examples.
Use a named import: `import { unzip } from 'unzipit';`.Use ES Module `import` statements (e.g., `import { unzip } from 'unzipit'`) or ensure your Node.js project is configured for CommonJS (`"type": "commonjs"` in `package.json`).Ensure `workerURL` is a valid, publicly accessible URL relative to your web application's origin, or a data URL. Double-check the path to `unzipit-worker.module.js` in your `dist` folder.
No dependency data recorded yet.