From 678eea82bd468cfd35c9a899cac11a2a3639d687 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Sat, 14 Dec 2019 10:56:51 -0500 Subject: [PATCH] buffer: use for...of --- lib/buffer.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 955a240fa39bf3..42315ba809e881 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -524,7 +524,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); } @@ -534,9 +533,9 @@ Buffer.concat = function concat(list, length) { if (length === undefined) { length = 0; - for (i = 0; i < list.length; i++) { - if (list[i].length) { - length += list[i].length; + for (const listEntry of list) { + if (listEntry.length) { + length += listEntry.length; } } } else { @@ -545,7 +544,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.