Code coverage report for lib/_stream_duplex.js

Statements: 96.55% (28 / 29)      Branches: 95% (19 / 20)      Functions: 100% (3 / 3)      Lines: 96.55% (28 / 29)      Ignored: none     

All files » lib/ » _stream_duplex.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60              946   946 946 946   946   946 946 7568 7568 6622     946 4454     4454 4454   4454 675   4454 554   4454 4454 848   4454       946     1489 1096       393     946 393        
(function () { // a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
// Writable.
 
'use strict';
 
module.exports = Duplex;
 
const util = require('util');
const Readable = require('_stream_readable');
const Writable = require('_stream_writable');
 
util.inherits(Duplex, Readable);
 
var keys = Object.keys(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) {
  Iif (!(this instanceof Duplex))
    return new Duplex(options);
 
  Readable.call(this, options);
  Writable.call(this, options);
 
  if (options && options.readable === false)
    this.readable = false;
 
  if (options && options.writable === false)
    this.writable = false;
 
  this.allowHalfOpen = true;
  if (options && options.allowHalfOpen === false)
    this.allowHalfOpen = false;
 
  this.once('end', onend);
}
 
// the no-half-open enforcer
function onend() {
  // if we allow half-open state, or if the writable side ended,
  // then we're ok.
  if (this.allowHalfOpen || this._writableState.ended)
    return;
 
  // no more data can be written.
  // But allow more writes to happen in this tick.
  process.nextTick(onEndNT, this);
}
 
function onEndNT(self) {
  self.end();
}
 
}());