Skip to content

Commit 276dfec

Browse files
committed
fixup
1 parent d6f1c7d commit 276dfec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/internal/streams/readable.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {
378378
if ((state.state & kObjectMode) === 0) {
379379
if (typeof chunk === 'string') {
380380
encoding = encoding || ((state.state & kDefaultUTF8Encoding) !== 0 ? 'utf8' : state[kDefaultEncodingValue]);
381-
if ((state.state | kEncoding) === 0 || state.encoding !== encoding) {
382-
if (addToFront && state.encoding) {
381+
if ((state.state & kEncoding) === 0 || state.encoding !== encoding) {
382+
if (addToFront && (state.state & kEncoding) !== 0) {
383383
// When unshifting, if state.encoding is set, we have to save
384384
// the string in the BufferList with the state encoding.
385385
chunk = Buffer.from(chunk, encoding).toString(state.encoding);
@@ -412,7 +412,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {
412412
return false;
413413
else
414414
addChunk(stream, state, chunk, true);
415-
} else if (state.ended) {
415+
} else if ((state.state & kEnded) !== 0) {
416416
errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
417417
} else if ((state.state & (kDestroyed | kErrored)) !== 0) {
418418
return false;
@@ -436,7 +436,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {
436436
// We can push more data if we are below the highWaterMark.
437437
// Also, if we have no data yet, we can stand some more bytes.
438438
// This is to work around cases where hwm=0, such as the repl.
439-
return !state.ended &&
439+
return (state.state & kEnded) === 0 &&
440440
(state.length < state.highWaterMark || state.length === 0);
441441
}
442442

0 commit comments

Comments
 (0)