Permalink
Browse files

small stream API improvement: stream.write(_, null) is now equivalent…

… to stream.end()
  • Loading branch information...
bjouhier committed Oct 9, 2012
1 parent f18f790 commit e77d0d4e03f40240e7875c1d7f8140cce248efe1
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/streams/server/streams._js
@@ -317,7 +317,12 @@ function WritableStream(emitter, options) {
/// Returns `this` for chaining.
self.write = function(_, data, enc) {
if (_error) throw new Error(_error.message);
- if (!emitter.write(data, enc)) _drain(_);
+ // data == null means end
+ if (data != null) {
+ if (!emitter.write(data, enc)) _drain(_);
+ } else {
+ emitter.end();
+ }
return self;
}
/// * `stream.end()`

0 comments on commit e77d0d4

Please sign in to comment.