|
@ -382,7 +382,7 @@ Object.defineProperty(Stream.prototype, 'readyState', { |
|
|
Stream.prototype.write = function (data, encoding) { |
|
|
Stream.prototype.write = function (data, encoding) { |
|
|
if (this._writeQueue && this._writeQueue.length) { |
|
|
if (this._writeQueue && this._writeQueue.length) { |
|
|
// Slow. There is already a write queue, so let's append to it.
|
|
|
// Slow. There is already a write queue, so let's append to it.
|
|
|
if (this._writeQueueLast() == END_OF_FILE) { |
|
|
if (this._writeQueueLast() === END_OF_FILE) { |
|
|
throw new Error('Stream.close() called already; cannot write.'); |
|
|
throw new Error('Stream.close() called already; cannot write.'); |
|
|
} |
|
|
} |
|
|
this._writeQueue.push(data); // TODO if string of the same encoding concat?
|
|
|
this._writeQueue.push(data); // TODO if string of the same encoding concat?
|
|
@ -511,7 +511,7 @@ Stream.prototype.flush = function () { |
|
|
var data = this._writeQueue.shift(); |
|
|
var data = this._writeQueue.shift(); |
|
|
var encoding = this._writeQueueEncoding.shift(); |
|
|
var encoding = this._writeQueueEncoding.shift(); |
|
|
|
|
|
|
|
|
if (data == END_OF_FILE) { |
|
|
if (data === END_OF_FILE) { |
|
|
this._shutdown(); |
|
|
this._shutdown(); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -714,7 +714,7 @@ Stream.prototype.close = function (data, encoding) { |
|
|
Stream.prototype.end = function (data, encoding) { |
|
|
Stream.prototype.end = function (data, encoding) { |
|
|
if (this.writable) { |
|
|
if (this.writable) { |
|
|
if (data) this.write(data, encoding); |
|
|
if (data) this.write(data, encoding); |
|
|
if (this._writeQueueLast() != END_OF_FILE) { |
|
|
if (this._writeQueueLast() !== END_OF_FILE) { |
|
|
this._writeQueue.push(END_OF_FILE); |
|
|
this._writeQueue.push(END_OF_FILE); |
|
|
this.flush(); |
|
|
this.flush(); |
|
|
} |
|
|
} |
|
|