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.6.0 to 0.7.0

test/parseContent.js

19

lib/parse.js

@@ -75,2 +75,3 @@ var util = require('util');

var entry = Stream.PassThrough();
entry.autodrain = function() {

@@ -83,2 +84,20 @@ return new Promise(function(resolve,reject) {

};
entry.buffer = function() {
return new Promise(function(resolve,reject) {
var buffer = new Buffer(''),
bufferStream = Stream.Transform()
.on('finish',function() {
resolve(buffer);
})
.on('error',reject);
bufferStream._transform = function(d,e,cb) {
buffer = Buffer.concat([buffer,d]);
cb();
};
entry.pipe(bufferStream);
});
};
entry.path = fileName;

@@ -85,0 +104,0 @@ entry.props = {};

2

package.json
{
"name": "unzipper",
"version": "0.6.0",
"version": "0.7.0",
"description": "Unzip cross-platform streaming API ",

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

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

### Buffering the content of an entry into memory
While the recommended strategy of consuming the unzipped contents is using streams, it is sometimes convenient to be able to get the full buffered contents of each file . Each `entry` provides a `.buffer` function that consumes the entry by buffering the contents into memory and returning a promise to the complete buffer.
```js
fs.createReadStream('path/to/archive.zip')
.pipe(unzipper.Parse())
.pipe(etl.map(entry => {
if (entry.path == "this IS the file I'm looking for")
entry
.buffer()
.then(content => fs.writeFile('output/path',content))
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