Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup: typeof before instanceof
  • Loading branch information
ronag committed Jan 1, 2020
commit c0112cf6695cd7fe63f1a5aac474df667fae77f9
6 changes: 3 additions & 3 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {

let err;
if (!state.objectMode) {
if (chunk instanceof Buffer) {
encoding = '';
} else if (typeof chunk === 'string') {
if (typeof chunk === 'string') {
encoding = encoding || state.defaultEncoding;
if (addToFront && state.encoding && state.encoding !== encoding) {
// When unshifting, if state.encoding is set, we have to save
Expand All @@ -289,6 +287,8 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {
chunk = Buffer.from(chunk, encoding);
encoding = '';
}
} else if (chunk instanceof Buffer) {
encoding = '';
} else if (Stream._isUint8Array(chunk)) {
chunk = Stream._uint8ArrayToBuffer(chunk);
encoding = '';
Expand Down