Skip to content

Commit e543d35

Browse files
ronagtargos
authored andcommitted
stream: inline and simplify onwritedrain
Inline and simplify onwritedrain. Also remove comment that seems to be outdated/invalid. PR-URL: #29037 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent c396b2a commit e543d35

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

‎lib/_stream_writable.js‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -478,21 +478,13 @@ function onwrite(stream, er){
478478
}
479479

480480
functionafterWrite(stream,state,finished,cb){
481-
if(!finished)
482-
onwriteDrain(stream,state);
483-
state.pendingcb--;
484-
cb();
485-
finishMaybe(stream,state);
486-
}
487-
488-
// Must force callback to be called on nextTick, so that we don't
489-
// emit 'drain' before the write() consumer gets the 'false' return
490-
// value, and has a chance to attach a 'drain' listener.
491-
functiononwriteDrain(stream,state){
492-
if(state.length===0&&state.needDrain){
481+
if(!finished&&state.length===0&&state.needDrain){
493482
state.needDrain=false;
494483
stream.emit('drain');
495484
}
485+
state.pendingcb--;
486+
cb();
487+
finishMaybe(stream,state);
496488
}
497489

498490
// If there's something in the buffer waiting, then process it

0 commit comments

Comments
(0)