parent
1ab98a130e
commit
82fca9136d
@ -426,6 +426,7 @@ Writable.prototype.end = function(chunk, encoding, cb) {
|
|||||||
function needFinish(stream, state) {
|
function needFinish(stream, state) {
|
||||||
return (state.ending &&
|
return (state.ending &&
|
||||||
state.length === 0 &&
|
state.length === 0 &&
|
||||||
|
state.buffer.length === 0 &&
|
||||||
!state.finished &&
|
!state.finished &&
|
||||||
!state.writing);
|
!state.writing);
|
||||||
}
|
}
|
||||||
|
@ -391,3 +391,15 @@ test('finish does not come before sync _write cb', function(t) {
|
|||||||
});
|
});
|
||||||
w.end();
|
w.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('finish is emitted if last chunk is empty', function(t) {
|
||||||
|
var w = new W();
|
||||||
|
w._write = function(chunk, e, cb) {
|
||||||
|
process.nextTick(cb);
|
||||||
|
};
|
||||||
|
w.on('finish', function() {
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
w.write(Buffer(1));
|
||||||
|
w.end(Buffer(0));
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user