Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unzipper

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unzipper - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

test/streamSingleEntry.js

11

lib/parse.js

@@ -100,3 +100,6 @@ var util = require('util');

self.emit('entry', entry);
if (self._readableState.pipesCount)
self.push(entry);
self.pull(vars.extraFieldLength).then(function(extraField) {

@@ -107,4 +110,2 @@ var fileSizeKnown = !(vars.flags & 0x08),

var inflater = vars.compressionMethod ? zlib.createInflateRaw() : Stream.PassThrough();
if (self.listenerCount && !self.listenerCount('entry'))
inflater = NoopStream();

@@ -199,6 +200,8 @@ if (fileSizeKnown) {

comment = comment.toString('utf8');
return self.end();
self.end();
self.push(null);
});
} else {
self.end();
self.push(null);
}

@@ -205,0 +208,0 @@ });

@@ -14,7 +14,7 @@ var Stream = require('stream');

Stream.Writable.call(this,{decodeStrings:false});
Stream.Duplex.call(this,{decodeStrings:false, objectMode:true});
this.buffer = new Buffer('');
}
util.inherits(PullStream,Stream.Writable);
util.inherits(PullStream,Stream.Duplex);

@@ -21,0 +21,0 @@ PullStream.prototype._write = function(chunk,e,cb) {

{
"name": "unzipper",
"version": "0.4.1",
"version": "0.5.0",
"description": "Unzip cross-platform streaming API ",

@@ -5,0 +5,0 @@ "author": "Evan Oxfeld <eoxfeld@gmail.com>",

@@ -7,4 +7,6 @@ # unzipper [![Build Status](https://api.travis-ci.org/ZJONSSON/node-unzipper.png)](https://api.travis-ci.org/ZJONSSON/node-unzipper)

The stucture of this fork is identical to the original, but uses ES6, Promises and inherit guarantees provided by node streams to ensure low memory footprint and guarantee finish/close events at the end of processing.
The stucture of this fork is similar to the original, but uses Promises and inherit guarantees provided by node streams to ensure low memory footprint and guarantee finish/close events at the end of processing. The new `Parser` will push any parsed `entries` downstream if you pipe from it, while still supporting the legacy `entry` event as well.
Breaking changes: The new `Parser` will not automatically drain entries if there are no listeners or pipes in place.
Unzipper provides simple APIs similar to [node-tar](https://github.com/isaacs/node-tar) for parsing and extracting zip files.

@@ -50,15 +52,47 @@ There are no added compiled dependencies - inflation is handled by node.js's built in zlib support.

```
### Parse zip by piping entries downstream
Or pipe the output of unzipper.Parse() to fstream
If you `pipe` from unzipper the downstream components will receive each `entry` for further processing. This allows for clean pipelines transforming zipfiles into unzipped data.
Example using `stream.Transform`:
```js
var readStream = fs.createReadStream('path/to/archive.zip');
var writeStream = fstream.Writer('output/path');
fs.createReadStream('path/to/archive.zip')
.pipe(unzipper.Parse())
.pipe(stream.Transform({
objectMode: true,
_transform: function(entry,e,cb) {
var fileName = entry.path;
var type = entry.type; // 'Directory' or 'File'
var size = entry.size;
if (fileName === "this IS the file I'm looking for") {
entry.pipe(fs.createWriteStream('output/path'))
.on('finish',cb);
} else {
entry.autodrain();
cb();
}
}
}
}));
```
readStream
Example using [etl](https://www.npmjs.com/package/etl):
```js
fs.createReadStream('path/to/archive.zip')
.pipe(unzipper.Parse())
.pipe(writeStream)
.pipe(etl.map(entry => {
if (entry.path == "this IS the file I'm looking for")
return entry
.pipe(etl.toFile('output/path'))
.promise();
else
entry.autodrain();
}))
```
## Licenses
See LICENCE
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc