From 46aa4810adad10785a03223d42c371df4af0f56a Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sun, 20 Oct 2019 07:21:50 +0200 Subject: [PATCH] stream: remove dead code `String.prototype.split()` returns an array of strings so the branch is never taken. Fixes: https://github.com/nodejs/node/issues/30040 PR-URL: https://github.com/nodejs/node/pull/30041 Reviewed-By: Yongsheng Zhang Reviewed-By: David Carlier Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Jiawen Geng Reviewed-By: Trivikram Kamat Reviewed-By: Matteo Collina --- lib/stream.js | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/stream.js b/lib/stream.js index 826f0e6d9adb6c..ff8838f4251594 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -43,23 +43,18 @@ Stream.Stream = Stream; Stream._isUint8Array = require('internal/util/types').isUint8Array; -const version = process.version.substr(1).split('.'); -if (version[0] === 0 && version[1] < 12) { - Stream._uint8ArrayToBuffer = Buffer; -} else { - try { - const internalBuffer = require('internal/buffer'); - Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) { - return new internalBuffer.FastBuffer(chunk.buffer, - chunk.byteOffset, - chunk.byteLength); - }; - } catch (e) { // eslint-disable-line no-unused-vars - } +try { + const internalBuffer = require('internal/buffer'); + Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) { + return new internalBuffer.FastBuffer(chunk.buffer, + chunk.byteOffset, + chunk.byteLength); + }; +} catch (e) { // eslint-disable-line no-unused-vars +} - if (!Stream._uint8ArrayToBuffer) { - Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) { - return Buffer.prototype.slice.call(chunk); - }; - } +if (!Stream._uint8ArrayToBuffer) { + Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) { + return Buffer.prototype.slice.call(chunk); + }; }