Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Sep 29, 2023
1 parent d6f1c7d commit 276dfec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit 276dfec

Please sign in to comment.