Skip to content

Commit c0112cf

Browse files
committed
fixup: typeof before instanceof
1 parent 55dbada commit c0112cf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/_stream_readable.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {
277277

278278
let err;
279279
if (!state.objectMode) {
280-
if (chunk instanceof Buffer) {
281-
encoding = '';
282-
} else if (typeof chunk === 'string') {
280+
if (typeof chunk === 'string') {
283281
encoding = encoding || state.defaultEncoding;
284282
if (addToFront && state.encoding && state.encoding !== encoding) {
285283
// When unshifting, if state.encoding is set, we have to save
@@ -289,6 +287,8 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {
289287
chunk = Buffer.from(chunk, encoding);
290288
encoding = '';
291289
}
290+
} else if (chunk instanceof Buffer) {
291+
encoding = '';
292292
} else if (Stream._isUint8Array(chunk)) {
293293
chunk = Stream._uint8ArrayToBuffer(chunk);
294294
encoding = '';

0 commit comments

Comments
 (0)