UNPKG

2.36 kBMarkdownView Raw
1# unzip
2
3Streaming cross-platform unzip tool written in node.js.
4
5Unzip provides simple APIs similar to [node-tar](https://github.com/isaacs/node-tar) for parsing and extracting zip files.
6There are no added compiled dependencies - inflation is handled by node.js's built in zlib support. Unzip is also an
7example use case of [node-pullstream](https://github.com/nearinfinity/node-pullstream).
8
9## Installation
10
11```bash
12$ npm install unzip
13```
14
15## Quick Examples
16
17### Extract to a directory
18```javascript
19fs.createReadStream('path/to/archive.zip').pipe(unzip.Extract({ path: 'output/path' }));
20```
21
22Extract emits the 'close' event once the zip's contents have been fully extracted to disk.
23
24### Parse zip file contents
25
26Process each zip file entry or pipe entries to another stream
27
28```javascript
29fs.createReadStream('path/to/archive.zip')
30 .pipe(unzip.Parse())
31 .on('entry', function (entry) {
32 var fileName = entry.path;
33 var type = entry.type; // 'Directory' or 'File'
34 var size = entry.size;
35 ...
36 });
37```
38
39Or pipe the output of unzip.Parse() to fstream
40
41```javascript
42var readStream = fs.createReadStream('path/to/archive.zip');
43var writeStream = fstream.Writer('output/path');
44
45readStream
46 .pipe(unzip.Parse())
47 .pipe(writeStream)
48```
49
50## License
51
52(The MIT License)
53
54Copyright (c) 2012 Near Infinity Corporation
55
56Permission is hereby granted, free of charge, to any person obtaining
57a copy of this software and associated documentation files (the
58"Software"), to deal in the Software without restriction, including
59without limitation the rights to use, copy, modify, merge, publish,
60distribute, sublicense, and/or sell copies of the Software, and to
61permit persons to whom the Software is furnished to do so, subject to
62the following conditions:
63
64The above copyright notice and this permission notice shall be
65included in all copies or substantial portions of the Software.
66
67THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
68EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
69MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
70NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
71LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
72OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
73WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\No newline at end of file