Skip to content

Commit

Permalink
stream: simplify writable's validChunk()
Browse files Browse the repository at this point in the history
This commit simplifies validChunk() by removing an unnecessary
intermediate variable.

PR-URL: #20696
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cjihrig authored and MylesBorins committed May 22, 2018
1 parent 981a2f7 commit 39a4112
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ function writeAfterEnd(stream, cb) {
// mode the stream is in. Currently this means that `null` is never accepted
// and undefined/non-string values are only allowed in object mode.
function validChunk(stream, state, chunk, cb) {
var valid = true;
var er;

if (chunk === null) {
Expand All @@ -261,9 +260,9 @@ function validChunk(stream, state, chunk, cb) {
if (er) {
stream.emit('error', er);
process.nextTick(cb, er);
valid = false;
return false;
}
return valid;
return true;
}

Writable.prototype.write = function(chunk, encoding, cb) {
Expand Down

0 comments on commit 39a4112

Please sign in to comment.