Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevva/decompress
Extracting archives made easy
https://github.com/kevva/decompress
decompress extract nodejs tar targz zip
Last synced: 9 days ago
JSON representation
Extracting archives made easy
- Host: GitHub
- URL: https://github.com/kevva/decompress
- Owner: kevva
- License: mit
- Created: 2013-08-23T14:52:29.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T19:01:33.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T01:06:40.257Z (28 days ago)
- Topics: decompress, extract, nodejs, tar, targz, zip
- Language: JavaScript
- Homepage:
- Size: 107 KB
- Stars: 415
- Watchers: 13
- Forks: 51
- Open Issues: 44
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome-nodejs-cn - decompress - 解压模块,支持 `tar`、```tar.gz``` 和 ```zip``` 文件开箱即用 (包 / 压缩)
- awesome-nodejs - decompress - Extracting archives made easy - ★ 249 (Compression)
- awesome-node - decompress - Decompression module with support for `tar`, `tar.gz` and `zip` files out of the box. (Packages / Compression)
- awesome-nodejs-cn - decompress - 解压模块,支持tar、tar.gz和zip文件开箱即用. (目录 / 压缩)
README
# decompress [![Build Status](https://travis-ci.org/kevva/decompress.svg?branch=master)](https://travis-ci.org/kevva/decompress)
> Extracting archives made easy
*See [decompress-cli](https://github.com/kevva/decompress-cli) for the command-line version.*
## Install
```
$ npm install decompress
```## Usage
```js
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:
```js
{
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:
```js
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:
```js
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](https://www.npmjs.com/browse/keyword/decompressplugin) to use.
##### strip
Type: `number`
Default: `0`Remove leading directory components from extracted files.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)