diff options
Diffstat (limited to 'node_modules/readable-stream/lib/_stream_duplex.js')
-rw-r--r-- | node_modules/readable-stream/lib/_stream_duplex.js | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/node_modules/readable-stream/lib/_stream_duplex.js b/node_modules/readable-stream/lib/_stream_duplex.js index c599463dd..a1ca813e5 100644 --- a/node_modules/readable-stream/lib/_stream_duplex.js +++ b/node_modules/readable-stream/lib/_stream_duplex.js @@ -28,7 +28,7 @@ /*<replacement>*/ -var processNextTick = require('process-nextick-args'); +var pna = require('process-nextick-args'); /*</replacement>*/ /*<replacement>*/ @@ -52,10 +52,13 @@ var Writable = require('./_stream_writable'); util.inherits(Duplex, Readable); -var keys = objectKeys(Writable.prototype); -for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; +{ + // avoid scope creep, the keys array can then be collected + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } } function Duplex(options) { @@ -74,6 +77,16 @@ function Duplex(options) { this.once('end', onend); } +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + // the no-half-open enforcer function onend() { // if we allow half-open state, or if the writable side ended, @@ -82,7 +95,7 @@ function onend() { // no more data can be written. // But allow more writes to happen in this tick. - processNextTick(onEndNT, this); + pna.nextTick(onEndNT, this); } function onEndNT(self) { @@ -114,11 +127,5 @@ Duplex.prototype._destroy = function (err, cb) { this.push(null); this.end(); - processNextTick(cb, err); -}; - -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } -}
\ No newline at end of file + pna.nextTick(cb, err); +};
\ No newline at end of file |