Skip to content

Commit e66fe47

Browse files
committed
stream: avoid possible slow path w UInt8Array
A chunk validity checks verifie if a chunk is a UInt8Array. We should defer it as it might be very expensive in older Node.js platforms.
1 parent b714060 commit e66fe47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/_stream_writable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function validChunk(stream, state, chunk, cb) {
248248
Writable.prototype.write = function(chunk, encoding, cb) {
249249
var state = this._writableState;
250250
var ret = false;
251-
var isBuf = Stream._isUint8Array(chunk) && !state.objectMode;
251+
var isBuf = !state.objectMode && Stream._isUint8Array(chunk);
252252

253253
if (isBuf && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
254254
chunk = Stream._uint8ArrayToBuffer(chunk);

0 commit comments

Comments
 (0)