Permalink
Browse files

stream: avoid instanceof

PR-URL: #10558
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
  • Loading branch information...
mscdex committed Dec 31, 2016
1 parent a3539ae commit 03b9f6fe26654e916f5e2dc7e9154ed51e5f1e99
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/_stream_writable.js
View
@@ -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;

0 comments on commit 03b9f6f

Please sign in to comment.