From 276dfec9078dd21fdaab167af79a55cc118b361b Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 29 Sep 2023 21:14:15 +0200 Subject: [PATCH] fixup --- lib/internal/streams/readable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index 705023467f6ce1..4346094f98f7f4 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -378,8 +378,8 @@ function readableAddChunk(stream, chunk, encoding, addToFront) { if ((state.state & kObjectMode) === 0) { if (typeof chunk === 'string') { encoding = encoding || ((state.state & kDefaultUTF8Encoding) !== 0 ? 'utf8' : state[kDefaultEncodingValue]); - if ((state.state | kEncoding) === 0 || state.encoding !== encoding) { - if (addToFront && state.encoding) { + if ((state.state & kEncoding) === 0 || state.encoding !== encoding) { + if (addToFront && (state.state & kEncoding) !== 0) { // When unshifting, if state.encoding is set, we have to save // the string in the BufferList with the state encoding. chunk = Buffer.from(chunk, encoding).toString(state.encoding); @@ -412,7 +412,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) { return false; else addChunk(stream, state, chunk, true); - } else if (state.ended) { + } else if ((state.state & kEnded) !== 0) { errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); } else if ((state.state & (kDestroyed | kErrored)) !== 0) { return false; @@ -436,7 +436,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) { // We can push more data if we are below the highWaterMark. // Also, if we have no data yet, we can stand some more bytes. // This is to work around cases where hwm=0, such as the repl. - return !state.ended && + return (state.state & kEnded) === 0 && (state.length < state.highWaterMark || state.length === 0); }