Comparing version 0.7.0 to 0.7.1
@@ -227,2 +227,10 @@ var util = require('util'); | ||
Parse.prototype.promise = function() { | ||
var self = this; | ||
return new Promise(function(resolve,reject) { | ||
self.on('finish',resolve); | ||
self.on('error',reject); | ||
}); | ||
}; | ||
module.exports = Parse; |
{ | ||
"name": "unzipper", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Unzip cross-platform streaming API ", | ||
@@ -5,0 +5,0 @@ "author": "Evan Oxfeld <eoxfeld@gmail.com>", |
@@ -121,5 +121,20 @@ # unzipper [![Build Status](https://api.travis-ci.org/ZJONSSON/node-unzipper.png)](https://api.travis-ci.org/ZJONSSON/node-unzipper) | ||
})) | ||
``` | ||
### Parse.promise() syntax sugar | ||
The parser emits `finish` and `error` events like any other stream. The parser additionally provides a promise wrapper around those two events to allow easy folding into existing Promise based structures. | ||
Example: | ||
```js | ||
fs.createReadStream('path/to/archive.zip') | ||
.pipe(unzipper.Parse() | ||
.on('entry', entry => entry.autodrain()) | ||
.promise() | ||
.then( () => console.log('done'), e => console.log('error',e)); | ||
``` | ||
## Licenses | ||
See LICENCE |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42492
30
655
139
9