diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/duplexify/index.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/duplexify/index.js')
-rw-r--r-- | node_modules/duplexify/index.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/node_modules/duplexify/index.js b/node_modules/duplexify/index.js index a04f124fa..ad36962c5 100644 --- a/node_modules/duplexify/index.js +++ b/node_modules/duplexify/index.js @@ -3,16 +3,22 @@ var eos = require('end-of-stream') var inherits = require('inherits') var shift = require('stream-shift') -var SIGNAL_FLUSH = new Buffer([0]) +var SIGNAL_FLUSH = (Buffer.from && Buffer.from !== Uint8Array.from) + ? Buffer.from([0]) + : new Buffer([0]) var onuncork = function(self, fn) { if (self._corked) self.once('uncork', fn) else fn() } +var autoDestroy = function (self, err) { + if (self._autoDestroy) self.destroy(err) +} + var destroyer = function(self, end) { return function(err) { - if (err) self.destroy(err.message === 'premature close' ? null : err) + if (err) autoDestroy(self, err.message === 'premature close' ? null : err) else if (end && !self._ended) self.end() } } @@ -37,6 +43,7 @@ var Duplexify = function(writable, readable, opts) { this._readable = null this._readable2 = null + this._autoDestroy = !opts || opts.autoDestroy !== false this._forwardDestroy = !opts || opts.destroy !== false this._forwardEnd = !opts || opts.end !== false this._corked = 1 // start corked |