Skip to content

Commit

Permalink
Push falsey values, and also emit the bytesRead for strings when emit…
Browse files Browse the repository at this point in the history
…ting the "data" event.
  • Loading branch information
isaacs committed Jan 26, 2010
1 parent 3e302e5 commit 8a075cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ejsgi/stream.js
Expand Up @@ -17,7 +17,7 @@ function Stream () {
this.write = function (data) {
if (buffer.closed) throw new Error("Cannot write after EOF.");
if (data === null) buffer.closed = true;
if (data || data === null) buffer.push(data);
buffer.push(data);
flow(this, buffer);
};
this.close = function () {
Expand All @@ -35,7 +35,7 @@ function flow (emitter, buffer) {
return;
}
var chunk = buffer.shift();
emitter.emit("data", chunk);
emitter.emit("data", chunk, (typeof(chunk) === "string" ? chunk.length : undefined));
if (chunk === null) {
emitter.emit("eof");
return;
Expand Down

0 comments on commit 8a075cd

Please sign in to comment.