JSPM

  • Created
  • Published
  • Downloads 3105518
  • Score
    100M100P100Q189121F
  • License MIT

Easily extract zip, tar and tar.gz archives

Package Exports

  • decompress

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (decompress) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

decompress Build Status

Easily extract .zip, .tar and .tar.gz archives. Based on the extract utility in Bower.

Getting started

Install with npm: npm install decompress

Examples

You'll only need to pass a type into ext and it'll figure the rest out for you.

var decompress = require('decompress');
var fs = require('fs');

var src = fs.createReadStream('foo.tar.gz');
var dest = decompress({ ext: '.tar.gz' });

src.pipe(dest);

API

decompress(opts)

Extract an archive using the ext option to determine which extractor to use. If no path is specified it'll extract it to your current location.

decompress.canExtract(src, mime)

Determine if a file can be extracted or not by checking the file extension and/or the MIME type.

decompress.canExtract('foo.zip');
// => true

decompress.canExtract('application/zip');
// => true

Options

ext

Type: String
Default: ''

String that can be a file name, URL, MIME type etc.

path

Type: String
Default: process.cwd()

Path to extract the archive to. If no path is defined it'll extract it to your current location.

strip

Type: Number
Default: 0

Equivalent to --strip-components for tar.

License

MIT License (c) Kevin Mårtensson