From a9c34b4a80cf942a082379e3f1f3071238018076 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 12 May 2018 23:07:52 -0400 Subject: [PATCH] stream: simplify writable's validChunk() This commit simplifies validChunk() by removing an unnecessary intermediate variable. PR-URL: https://github.com/nodejs/node/pull/20696 Reviewed-By: Trivikram Kamat Reviewed-By: Daniel Bevenius Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: Jackson Tian Reviewed-By: Anna Henningsen Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell --- lib/_stream_writable.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 3df14206f17789..2f69ba931afa4b 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -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) { @@ -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) {