unzipper
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
big-integer | 1.6.52 | 30.58 kB | Unlicense | prod | |
binary | 0.3.0 | 9.53 kB | MIT | prod | 1 2 2 |
bluebird | 3.4.7 | 131.12 kB | MIT | prod | |
buffer-indexof-polyfill | 1.0.2 | 2.99 kB | MIT | prod | |
duplexer2 | 0.1.4 | 2.75 kB | BSD-3-Clause | prod | |
fstream | 1.0.12 | 16.61 kB | ISC | prod | |
listenercount | 1.0.1 | 1.87 kB | ISC | prod | |
readable-stream | 2.1.5 | 36.75 kB | MIT | prod | |
setimmediate | 1.0.5 | 3.18 kB | MIT | prod |
Unzipper, an active fork of "node-unzip", is a powerful tool packed with new features not present in the original. It offers cross-platform streaming APIs for parsing and extracting zip files. The software picks up where "node-unzip" left off, using Promises and the inherent guarantees provided by node streams to assure low memory footprint and consistent functionality of finish/close events at the end of processing.
To use unzipper, first install the package with the command npm install unzipper
. Once the installation process is completed, unleash the power of unzipper by importing it into your project via the require
function. Use fs.createReadStream('path/to/archive.zip').pipe(unzipper.Extract({ path: 'output/path' }));
to extract zip files to a particular directory. To process zip file entries or to pipe entries to another stream, use unzipper.Parse()
.
Here is a detailed example:
const unzipper = require('unzipper');
const fs = require('fs');
fs.createReadStream('path/to/archive.zip')
.pipe(unzipper.Parse())
.on('entry', function (entry) {
const fileName = entry.path;
const type = entry.type; // 'Directory' or 'File'
const size = entry.vars.uncompressedSize; // There is also compressedSize;
if (fileName === "this IS the file I'm looking for") {
entry.pipe(fs.createWriteStream('output/path'));
} else {
entry.autodrain();
}
});
The documentation for the Unzipper is primarily found in its README content of the package's GitHub page at "https://github.com/ZJONSSON/node-unzipper". The README file gives an exhaustive description of the functionality of the software, the different ways in which it can be used, and examples of code usage for different use cases.