decompress
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
decompress-tar | 4.1.1 | 1.97 kB | MIT | prod | |
decompress-tarbz2 | 4.1.1 | 1.74 kB | MIT | prod | |
decompress-targz | 4.1.1 | 1.74 kB | MIT | prod | |
decompress-unzip | 4.0.1 | 2.11 kB | MIT | prod | |
graceful-fs | 4.2.11 | 9.57 kB | ISC | prod | |
make-dir | 1.3.0 | 2.83 kB | MIT | prod | |
pify | 2.3.0 | 2.73 kB | MIT | prod | |
strip-dirs | 2.1.0 | 2.7 kB | MIT | prod |
Decompress is a popular npm package that simplifies the extraction of archives. It's a handy tool for developers, as it allows for the quick and easy unpacking of compressed files. This JavaScript utility supports various archive formats and offers additional features, such as file filtering and mapping, through its robust API. It also integrates with various decompress plugins to broaden its functionality. The open-source package is maintained by Kevin Mårtensson and distributed under the MIT License.
To use Decompress, you first need to install it by running the command npm install decompress
. After installation, you can require the package in your JavaScript project:
const decompress = require('decompress');
Using Decompress to extract files from an archive is straightforward:
decompress('unicorn.zip', 'dist').then(files => {
console.log('done!');
});
In this example, 'unicorn.zip' is the file to decompress, and 'dist' is the output directory. There's also an option to filter out certain file types before extracting. Here, '.exe' files are excluded from the extraction:
decompress('unicorn.zip', 'dist', {
filter: file => path.extname(file.path) !== '.exe'
}).then(files => {
console.log('done!');
});
In addition to filtering, Decompress also provides a mapping option:
decompress('unicorn.zip', 'dist', {
map: file => {
file.path = `unicorn-${file.path}`;
return file;
}
}).then(files => {
console.log('done!');
});
And a feature to remove leading directory components from extracted files.
When working with Decompress, take note that the filter
option is applied after all files from the archive have been fully read into memory. Despite the filter option, Decompress will read the entire compressed file into memory.
The official docs for Decompress can be found on the GitHub page of the repository: https://github.com/kevva/decompress. Here, you'll find comprehensive information about the usage, API, and options available with this utility, as well as links to related packages and plugins. In particular, the API section provides detailed descriptions of the input
, output
, and options
parameters, while the Usage section comes with illustrative code examples. A visit to the Decompress GitHub page is strongly recommended for anyone interested in using this highly versatile archive extraction tool.