Comparing version 3.5.1 to 3.5.2
15
index.js
@@ -15,3 +15,3 @@ var stream = require('readable-stream') | ||
return function(err) { | ||
if (err) self.destroy(err.message === 'premature close' ? null : err) | ||
if (err) self._destroyInterval(err) | ||
else if (end && !self._ended) self.end() | ||
@@ -50,2 +50,4 @@ } | ||
this._ended = false | ||
this._error = null | ||
this._preferError = false | ||
@@ -172,2 +174,4 @@ this.destroyed = false | ||
Duplexify.prototype.destroy = function(err) { | ||
if (this._preferError && !this._error && err) this._error = err | ||
if (this.destroyed) return | ||
@@ -178,6 +182,13 @@ this.destroyed = true | ||
process.nextTick(function() { | ||
self._destroy(err) | ||
self._destroy(self._preferError ? self._error : err) | ||
}) | ||
} | ||
Duplexify.prototype._destroyInterval = function(err) { | ||
if (this.destroyed) return | ||
if (err.message !== 'premature close') return this.destroy(err) | ||
this._forwardError = true | ||
this.destroy(null) | ||
} | ||
Duplexify.prototype._destroy = function(err) { | ||
@@ -184,0 +195,0 @@ if (err) { |
{ | ||
"name": "duplexify", | ||
"version": "3.5.1", | ||
"version": "3.5.2", | ||
"description": "Turn a writable and readable stream into a streams2 duplex stream with support for async initialization and streams1/streams2 input", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,3 +49,3 @@ # duplexify | ||
If the readable or writable streams emits an error or close it will destroy both streams and bubble up the event. | ||
You can also explictly destroy the streams by calling `dup.destroy()`. The `destroy` method optionally takes an | ||
You can also explicitly destroy the streams by calling `dup.destroy()`. The `destroy` method optionally takes an | ||
error object as argument, in which case the error is emitted as part of the `error` event. | ||
@@ -52,0 +52,0 @@ |
@@ -263,3 +263,2 @@ var tape = require('tape') | ||
var dup = duplexify(passthrough, passthrough) | ||
var ok = false | ||
@@ -266,0 +265,0 @@ passthrough.emit('close') |
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
17122
439
7