forked from antelle/node-stream-zip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
28 lines (28 loc) · 1.01 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
console.log('Loading zip...');
var StreamZip = require('./node_stream_zip.js');
var zip = new StreamZip({
file: './test/ok/normal.zip'
});
zip.on('error', function(err) { console.error('ERROR: ' + err); });
zip.on('ready', function() {
//console.dir(zip.entry('README.md'));
console.log('Done in ' + process.uptime() + '. Entries read: ' + zip.entriesCount);
//console.log(zip.entryDataSync('README.md').toString());
zip.stream('README.md', function(err, stm) {
if (err)
return console.error(err);
console.log('Entry data:\n');
stm.pipe(process.stdout);
});
//zip.extract('README.md', 'd:/temp/ext/', function(err) {
// console.log(err ? err : 'Entry extracted');
// zip.close();
//});
//zip.extract(null, 'd:/temp/ext', function(err, count) {
// console.log(err ? err : ('Extracted ' + count + ' entries'));
// zip.close();
//});
});
zip.on('extract', function(entry, file) {
console.log('extract', entry.name, file);
});