Skip to content

Commit

Permalink
stream: avoid instanceof
Browse files Browse the repository at this point in the history
PR-URL: #10558
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
  • Loading branch information
mscdex committed Jan 11, 2017
1 parent a3539ae commit 03b9f6f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ function decodeChunk(state, chunk, encoding) {
// If we return false, then we need a drain event, so set that flag.
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
if (!isBuf) {
chunk = decodeChunk(state, chunk, encoding);
if (chunk instanceof Buffer)
var newChunk = decodeChunk(state, chunk, encoding);
if (chunk !== newChunk) {
encoding = 'buffer';
chunk = newChunk;
}
}
var len = state.objectMode ? 1 : chunk.length;

Expand Down

0 comments on commit 03b9f6f

Please sign in to comment.