stream: avoid instanceof

PR-URL: https://github.com/nodejs/node/pull/10558
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
This commit is contained in:
Brian White 2016-12-31 16:33:36 -05:00
parent a3539ae3be
commit 03b9f6fe26
No known key found for this signature in database
GPG Key ID: 606D7358F94DA209

View File

@ -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;