decompress vs decompress-zip vs extract-zip vs unzipper
Node.js File Extraction Libraries
decompressdecompress-zipextract-zipunzipperSimilar Packages:

Node.js File Extraction Libraries

File extraction libraries in Node.js are essential tools for developers who need to handle compressed files in various formats. These libraries provide functionality to decompress and extract files from archives, enabling seamless file management and manipulation within applications. They support different compression formats, making it easier to work with files downloaded from the internet or packaged for distribution. Choosing the right library depends on specific project requirements, such as the types of archives to be handled, performance considerations, and ease of use.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
decompress0418-466 years agoMIT
decompress-zip0102-305 years agoMIT
extract-zip0398-556 years agoBSD-2-Clause
unzipper047456.6 kB862 years agoMIT

Feature Comparison: decompress vs decompress-zip vs extract-zip vs unzipper

Supported Formats

  • decompress:

    Supports multiple formats including .zip, .tar, .gz, .bz2, and more, allowing for flexible file handling in various scenarios.

  • decompress-zip:

    Specifically designed for .zip files, making it a focused solution for projects that primarily deal with this format.

  • extract-zip:

    Exclusively handles .zip files with a straightforward API, making it easy to extract contents without additional complexity.

  • unzipper:

    Primarily focused on .zip files and streams, providing a powerful interface for both extraction and streaming of files.

Ease of Use

  • decompress:

    Offers a simple and intuitive API, making it easy for developers to implement file extraction with minimal setup and configuration.

  • decompress-zip:

    Designed for simplicity, it allows quick extraction of .zip files with just a few lines of code, making it beginner-friendly.

  • extract-zip:

    Provides a very straightforward API for extracting .zip files, ideal for developers looking for a no-frills approach.

  • unzipper:

    While slightly more complex, it offers advanced features like streaming extraction, which can be beneficial for larger files.

Performance

  • decompress:

    Performance varies based on the format being extracted, but it is generally efficient for handling multiple formats in a single library.

  • decompress-zip:

    Optimized for .zip files, ensuring quick extraction times and minimal resource usage for this specific format.

  • extract-zip:

    Highly efficient for .zip files, focusing on performance and speed during extraction operations.

  • unzipper:

    Offers streaming capabilities which can improve performance for large .zip files, allowing for on-the-fly extraction.

Streaming Support

  • decompress:

    Does not inherently support streaming, focusing instead on batch extraction of files from various formats.

  • decompress-zip:

    No streaming support; designed for straightforward extraction of .zip files.

  • extract-zip:

    Does not support streaming; it is a simple extraction tool for .zip files without additional features.

  • unzipper:

    Provides robust streaming support, allowing files to be extracted directly to streams, which is useful for large files or when integrating with other stream-based processes.

Community and Maintenance

  • decompress:

    Actively maintained with a growing community, ensuring ongoing support and updates for various formats.

  • decompress-zip:

    Well-maintained, but with a narrower focus on .zip files, which may limit community contributions compared to more versatile libraries.

  • extract-zip:

    Maintained with a focus on .zip extraction, but may not have as large a community as more general libraries.

  • unzipper:

    Has a solid community and is actively maintained, especially for those needing advanced streaming capabilities.

How to Choose: decompress vs decompress-zip vs extract-zip vs unzipper

  • decompress:

    Choose 'decompress' if you need a versatile library that supports multiple archive formats (including .zip, .tar, .gz, etc.) and want a simple API for extracting files. It is ideal for projects requiring broad format support.

README for decompress

decompress Build Status

Extracting archives made easy

See decompress-cli for the command-line version.

Install

$ npm install decompress

Usage

const decompress = require('decompress');

decompress('unicorn.zip', 'dist').then(files => {
	console.log('done!');
});

API

decompress(input, [output], [options])

Returns a Promise for an array of files in the following format:

{
	data: Buffer,
	mode: Number,
	mtime: String,
	path: String,
	type: String
}

input

Type: string Buffer

File to decompress.

output

Type: string

Output directory.

options

filter

Type: Function

Filter out files before extracting. E.g:

decompress('unicorn.zip', 'dist', {
	filter: file => path.extname(file.path) !== '.exe'
}).then(files => {
	console.log('done!');
});

Note that in the current implementation, filter is only applied after fully reading all files from the archive in memory. Do not rely on this option to limit the amount of memory used by decompress to the size of the files included by filter. decompress will read the entire compressed file into memory regardless.

map

Type: Function

Map files before extracting: E.g:

decompress('unicorn.zip', 'dist', {
	map: file => {
		file.path = `unicorn-${file.path}`;
		return file;
	}
}).then(files => {
	console.log('done!');
});
plugins

Type: Array
Default: [decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()]

Array of plugins to use.

strip

Type: number
Default: 0

Remove leading directory components from extracted files.

License

MIT © Kevin Mårtensson