Socket
Socket
Sign inDemoInstall

decompress

Package Overview
Dependencies
135
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    decompress

Extracting archives made easy


Version published
Weekly downloads
2.8M
increased by0.4%
Maintainers
2
Created
Weekly downloads
 

Package description

What is decompress?

The decompress npm package is a module that allows for decompressing archive files such as zip, tar, tar.gz, and many others. It provides a simple API to easily extract files from these archives.

What are decompress's main functionalities?

Extracting archive files

This feature allows you to extract files from an archive like a zip file into a specified directory. The 'decompress' function returns a promise that resolves with an array of file objects when the extraction is complete.

const decompress = require('decompress');

decompress('unicorn.zip', 'dist').then(files => {
    console.log('Files decompressed successfully');
});

Extracting specific files

This feature allows you to extract only specific files from an archive by using a filter function. The filter function is passed each file object, and you return a boolean to indicate whether the file should be extracted.

const decompress = require('decompress');

const filesToExtract = ['unicorn.png', 'rainbow.jpg'];

decompress('archive.zip', 'dist', {
    filter: file => filesToExtract.includes(file.path)
}).then(files => {
    console.log('Selected files decompressed successfully');
});

Using plugins to handle different archive types

The decompress package can be extended with plugins to support more archive types. In this example, the 'decompress-targz' plugin is used to decompress a '.tar.gz' file.

const decompress = require('decompress');
const decompressTargz = require('decompress-targz');

decompress('unicorn.tar.gz', 'dist', {
    plugins: [
        decompressTargz()
    ]
}).then(files => {
    console.log('tar.gz file decompressed successfully');
});

Other packages similar to decompress

Readme

Source

decompress Build Status

Extracting archives made easy

See decompress-cli for the command-line version.

Install

$ npm install --save decompress

Usage

const Decompress = require('decompress');

new Decompress({mode: '755'})
	.src('foo.zip')
	.dest('dest')
	.use(Decompress.zip({strip: 1}))
	.run();

API

new Decompress(options)

Creates a new Decompress instance.

options.mode

Type: string

Set mode on the extracted files, i.e { mode: '755' }.

options.strip

Type: number

Equivalent to --strip-components for tar.

.src(files)

files

Type: array, buffer or string

Set the files to be extracted.

.dest(path)

path

Type: string

Set the destination to where your file will be extracted to.

.use(plugin)

plugin

Type: function

Add a plugin to the middleware stack.

.run(callback)

Extract your file with the given settings.

callback(err, files)

Type: function

The callback will return an array of vinyl files in files.

Plugins

The following plugins are bundled with decompress:

  • tar — Extract TAR files.
  • tar.bz2 — Extract TAR.BZ files.
  • tar.gz — Extract TAR.GZ files.
  • zip — Extract ZIP files.

.tar(options)

Extract TAR files.

const Decompress = require('decompress');

new Decompress()
	.use(Decompress.tar({strip: 1}));

.tarbz2(options)

Extract TAR.BZ files.

const Decompress = require('decompress');

new Decompress()
	.use(Decompress.tarbz2({strip: 1}));

.targz(options)

Extract TAR.GZ files.

const Decompress = require('decompress');

new Decompress()
	.use(Decompress.targz({strip: 1}));

.zip(options)

Extract ZIP files.

const Decompress = require('decompress');

new Decompress()
	.use(Decompress.zip({strip: 1}));

License

MIT © Kevin Mårtensson

Keywords

FAQs

Last updated on 20 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc