Permalink
Browse files

updates from core streams2 branch

  • Loading branch information...
1 parent 099a872 commit 7e09d0b7b36c7381b4408cebe68cc89cf66a46df @isaacs isaacs committed Dec 1, 2012
Showing with 494 additions and 196 deletions.
  1. +3 −24 duplex.js
  2. +303 −98 readable.js
  3. +27 −23 transform.js
  4. +161 −51 writable.js
View
@@ -47,38 +47,17 @@ function Duplex(options) {
if (options && options.allowHalfOpen === false)
this.allowHalfOpen = false;
- this.once('finish', onfinish);
this.once('end', onend);
}
-// the no-half-open enforcers.
-function onfinish() {
- // if we allow half-open state, or if the readable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._readableState.ended)
- return;
-
- // mark that we're done.
- this._readableState.ended = true;
-
- // tell the user
- if (this._readableState.length === 0)
- this.emit('end');
- else
- this.emit('readable');
-}
-
+// 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;
- // just in case the user is about to call write() again.
- this.write = function() {
- return false;
- };
-
// no more data can be written.
- this.end();
+ // But allow more writes to happen in this tick.
+ process.nextTick(this.end.bind(this));
}
Oops, something went wrong.

0 comments on commit 7e09d0b

Please sign in to comment.