unzip-stream is a Node.js library for processing zip files using a streaming API. It provides mechanisms to parse zip file contents entry by entry or extract an entire archive to a directory. The current stable version is 0.3.4, with a release cadence that appears to be maintenance-focused rather than frequent feature additions. Key differentiators include its streaming engine, which aims to handle zip files that might cause issues with older libraries like `unzip` or `unzipper`, and its reliance solely on Node.js's built-in zlib for inflation, avoiding compiled dependencies. It supports Zip64 for archives with files larger than 4GB. However, the library acknowledges that the zip file format is not inherently optimized for streaming, suggesting alternatives like `yauzl` or `decompress-zip` for scenarios where the complete zip file is available and random access is preferred. It lacks support for encrypted (password-protected) zips and symlinks.
npm install unzip-streamVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to parse a zip file, iterate through its entries, and selectively extract a specific file. It highlights the crucial `autodrain()` method for unconsumed entries and proper event handling.
Ensure every `entry` stream is either piped to a consumer (e.g., `fs.createWriteStream`) or explicitly calls `entry.autodrain()`.
Listen for the `'close'` event on the stream returned by `unzip.Extract()` instead of `'finish'` for reliable completion detection.
Upgrade to `unzip-stream@0.3.0` or later to ensure full compatibility with Zip64 archives and large file sizes.
Evaluate if a streaming approach is strictly necessary. For complete zip files, consider non-streaming libraries. For streaming, be prepared for potential edge case issues.
Ensure zip archives are not encrypted if using `unzip-stream`. For symlink support or encryption, choose an alternative library that explicitly offers these features.
Pass a `decodeString` option to `unzip.Parse()` or `unzip.Extract()` that utilizes a library like `iconv-lite` for correct character set decoding, e.g., `{ decodeString: (buffer) => iconvLite.decode(buffer, 'iso-8859-2') }`.For every `entry` object, either pipe it to a destination (e.g., `entry.pipe(fs.createWriteStream('path'))`) or call `entry.autodrain()` to dispose of its contents.Change event listener from `'finish'` to `'close'` when using `unzip.Extract()`: `stream.on('close', () => { /* extraction truly done */ });`Provide a custom `decodeString` function using a character encoding library (like `iconv-lite`) to `unzip.Parse()` or `unzip.Extract()`, e.g., `unzip.Parse({ decodeString: (buffer) => iconvLite.decode(buffer, 'cp866') })`.Upgrade your `unzip-stream` package to version `0.3.0` or newer: `npm install unzip-stream@latest`.
No dependency data recorded yet.