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