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 <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>
This commit is contained in:
cjihrig 2018-05-12 23:07:52 -04:00
parent faa2daed6c
commit a9c34b4a80
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -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) {