Skip to content
This repository
Browse code

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

… to stream.end()
  • Loading branch information...
commit e77d0d4e03f40240e7875c1d7f8140cce248efe1 1 parent f18f790
Bruno Jouhier authored October 09, 2012

Showing 1 changed file with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. 7  lib/streams/server/streams._js
7  lib/streams/server/streams._js
@@ -317,7 +317,12 @@ function WritableStream(emitter, options) {
317 317
 	///   Returns `this` for chaining.
318 318
 	self.write = function(_, data, enc) {
319 319
 		if (_error) throw new Error(_error.message);
320  
-		if (!emitter.write(data, enc)) _drain(_);
  320
+		// data == null means end
  321
+		if (data != null) {
  322
+			if (!emitter.write(data, enc)) _drain(_);
  323
+		} else {
  324
+			emitter.end();
  325
+		}
321 326
 		return self;
322 327
 	}
323 328
 	/// * `stream.end()`  

0 notes on commit e77d0d4

Please sign in to comment.
Something went wrong with that request. Please try again.