destroy accepts an error
This commit is contained in:
parent
4aa9728962
commit
cd3c9cc5f4
2 changed files with 7 additions and 6 deletions
|
@ -39,10 +39,7 @@ var Extract = function(opts) {
|
|||
|
||||
var onunlock = function(err) {
|
||||
self._locked = false;
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
return self.destroy();
|
||||
}
|
||||
if (err) return self.destroy(err);
|
||||
if (!self._stream) oncontinue();
|
||||
};
|
||||
|
||||
|
@ -90,9 +87,11 @@ var Extract = function(opts) {
|
|||
|
||||
util.inherits(Extract, stream.Writable);
|
||||
|
||||
Extract.prototype.destroy = function() {
|
||||
Extract.prototype.destroy = function(err) {
|
||||
if (this._destroyed) return;
|
||||
this._destroyed = true;
|
||||
|
||||
if (err) this.emit('error', err);
|
||||
this.emit('close');
|
||||
if (this._stream) this._stream.emit('close');
|
||||
};
|
||||
|
|
4
pack.js
4
pack.js
|
@ -120,9 +120,11 @@ Pack.prototype.finalize = function() {
|
|||
this.push(null);
|
||||
};
|
||||
|
||||
Pack.prototype.destroy = function() {
|
||||
Pack.prototype.destroy = function(err) {
|
||||
if (this._destroyed) return;
|
||||
this._destroyed = true;
|
||||
|
||||
if (err) this.emit('error', err);
|
||||
this.emit('close');
|
||||
if (this._stream && this._stream.destroy) this._stream.destroy();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue