Skip to content

Commit 39a4112

Browse files
cjihrigMylesBorins
authored andcommitted
stream: simplify writable's validChunk()
This commit simplifies validChunk() by removing an unnecessary intermediate variable. PR-URL: #20696 Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Jackson Tian <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 981a2f7 commit 39a4112

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/_stream_writable.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ function writeAfterEnd(stream, cb) {
250250
// mode the stream is in. Currently this means that `null` is never accepted
251251
// and undefined/non-string values are only allowed in object mode.
252252
function validChunk(stream, state, chunk, cb) {
253-
var valid = true;
254253
var er;
255254

256255
if (chunk === null) {
@@ -261,9 +260,9 @@ function validChunk(stream, state, chunk, cb) {
261260
if (er) {
262261
stream.emit('error', er);
263262
process.nextTick(cb, er);
264-
valid = false;
263+
return false;
265264
}
266-
return valid;
265+
return true;
267266
}
268267

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

0 commit comments

Comments
 (0)