From 9cd83c761f688079efeae931cb3462b9ba6d18e3 Mon Sep 17 00:00:00 2001 From: Nikolai Vavilov Date: Tue, 19 May 2020 17:51:55 +0300 Subject: [PATCH] buffer: remove hoisted variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33470 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Juan José Arboleda Reviewed-By: Ruben Bridgewater --- lib/buffer.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index a818f41a26ed5b..991c601072c585 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -544,7 +544,6 @@ Buffer.isEncoding = function isEncoding(encoding) { Buffer[kIsEncodingSymbol] = Buffer.isEncoding; Buffer.concat = function concat(list, length) { - let i; if (!ArrayIsArray(list)) { throw new ERR_INVALID_ARG_TYPE('list', 'Array', list); } @@ -554,7 +553,7 @@ Buffer.concat = function concat(list, length) { if (length === undefined) { length = 0; - for (i = 0; i < list.length; i++) { + for (let i = 0; i < list.length; i++) { if (list[i].length) { length += list[i].length; } @@ -565,7 +564,7 @@ Buffer.concat = function concat(list, length) { const buffer = Buffer.allocUnsafe(length); let pos = 0; - for (i = 0; i < list.length; i++) { + for (let i = 0; i < list.length; i++) { const buf = list[i]; if (!isUint8Array(buf)) { // TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE.