Skip to content

Commit

Permalink
fixup: typeof before instanceof
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jan 1, 2020
1 parent 55dbada commit c0112cf
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit c0112cf

Please sign in to comment.