diff --git a/index.js b/index.js index 4240cab1c9..6002cb0763 100644 --- a/index.js +++ b/index.js @@ -296,7 +296,7 @@ RedisClient.prototype.warn = function (msg) { RedisClient.prototype.flushAndError = function (errorAttributes, options) { options = options || {} const queueNames = options.queues || ['commandQueue', 'offlineQueue'] // Flush the commandQueue first to keep the order intact - for (let i = 0; i < queueNames.length; i++) { + for (var i = 0; i < queueNames.length; i++) { // If the command was fired it might have been processed so far if (queueNames[i] === 'commandQueue') { errorAttributes.message += ' It might have been processed.' @@ -304,7 +304,7 @@ RedisClient.prototype.flushAndError = function (errorAttributes, options) { errorAttributes.message = errorAttributes.message.replace(' It might have been processed.', '') } // Don't flush everything from the queue - for (let commandObj = this[queueNames[i]].shift(); commandObj; commandObj = this[queueNames[i]].shift()) { + for (var commandObj = this[queueNames[i]].shift(); commandObj; commandObj = this[queueNames[i]].shift()) { const err = new errorClasses.AbortError(errorAttributes) if (commandObj.error) { err.stack = err.stack + commandObj.error.stack.replace(/^Error.*?\n/, '\n') @@ -456,7 +456,7 @@ RedisClient.prototype.onInfoCmd = function (res) { } } - let retryTime = +this.serverInfo.loading_eta_seconds * 1000 + var retryTime = +this.serverInfo.loading_eta_seconds * 1000 if (retryTime > 1000) { retryTime = 1000 } @@ -477,7 +477,7 @@ RedisClient.prototype.readyCheck = function () { } RedisClient.prototype.sendOfflineQueue = function () { - for (let commandObj = this.offlineQueue.shift(); commandObj; commandObj = this.offlineQueue.shift()) { + for (var commandObj = this.offlineQueue.shift(); commandObj; commandObj = this.offlineQueue.shift()) { debug('Sending offline command: %s', commandObj.command) this.internalSendCommand(commandObj) } @@ -648,8 +648,8 @@ function subscribeUnsubscribe (self, reply, type) { if (commandObj.argsLength === 1 || self.subCommandsLeft === 1 || commandObj.argsLength === 0 && (count === 0 || channel === null)) { if (count === 0) { // unsubscribed from all channels - let runningCommand - let i = 1 + var runningCommand + var i = 1 self.pubSubMode = 0 // Deactivating pub sub mode // This should be a rare case and therefore handling it this way should be good performance wise for the general case for (runningCommand = self.commandQueue.get(i); runningCommand !== undefined; runningCommand = self.commandQueue.get(i)) { @@ -699,7 +699,7 @@ RedisClient.prototype.returnReply = function (reply) { // As this is not the average use case and monitor is expensive anyway, let's change the code here, to improve // the average performance of all other commands in case of no monitor mode if (this.monitoring) { - let replyStr + var replyStr if (this.buffers && Buffer.isBuffer(reply)) { replyStr = reply.toString() } else { @@ -731,8 +731,8 @@ RedisClient.prototype.returnReply = function (reply) { } function handleOfflineCommand (self, commandObj) { - let command = commandObj.command - let err, msg + var command = commandObj.command + var err, msg if (self.closing || !self.enableOfflineQueue) { command = command.toUpperCase() if (!self.closing) { @@ -793,8 +793,8 @@ RedisClient.prototype.internalSendCommand = function (commandObj) { } RedisClient.prototype.writeStrings = function () { - let str = '' - for (let command = this.pipelineQueue.shift(); command; command = this.pipelineQueue.shift()) { + var str = '' + for (var command = this.pipelineQueue.shift(); command; command = this.pipelineQueue.shift()) { // Write to stream if the string is bigger than 4mb. The biggest string may be Math.pow(2, 28) - 15 chars long if (str.length + command.length > 4 * 1024 * 1024) { this.shouldBuffer = !this.stream.write(str) @@ -808,7 +808,7 @@ RedisClient.prototype.writeStrings = function () { } RedisClient.prototype.writeBuffers = function () { - for (let command = this.pipelineQueue.shift(); command; command = this.pipelineQueue.shift()) { + for (var command = this.pipelineQueue.shift(); command; command = this.pipelineQueue.shift()) { this.shouldBuffer = !this.stream.write(command) } } diff --git a/lib/customErrors.js b/lib/customErrors.js index 43583fb867..f40f09facb 100644 --- a/lib/customErrors.js +++ b/lib/customErrors.js @@ -16,7 +16,7 @@ class AbortError extends RedisError { if (stack || stack === undefined) { Error.captureStackTrace(this, AbortError) } - for (let keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) { + for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) { this[key] = obj[key] } } diff --git a/lib/individualCommands.js b/lib/individualCommands.js index 7447e7d2bd..2d96f3fa57 100644 --- a/lib/individualCommands.js +++ b/lib/individualCommands.js @@ -117,7 +117,7 @@ function infoCallback (self) { const lines = res.toString().split('\r\n') var line, parts, subParts - for (let i = 0; i < lines.length; i++) { + for (var i = 0; i < lines.length; i++) { parts = lines[i].split(':') if (parts[1]) { if (parts[0].indexOf('db') === 0) { diff --git a/lib/multi.js b/lib/multi.js index c10be736bc..b7a1272f0b 100644 --- a/lib/multi.js +++ b/lib/multi.js @@ -90,7 +90,7 @@ function execTransaction (multi) { // Silently ignore this error. We'll receive the error for the exec as well const promises = [multi._client.internalSendCommand(new Command('multi', [])).catch(() => {})] // Drain queue, callback will catch 'QUEUED' or error - for (let index = 0; index < len; index++) { + for (var index = 0; index < len; index++) { // The commands may not be shifted off, since they are needed in the result handler promises.push(pipelineTransactionCommand(multi, multi._queue.get(index), index).catch((e) => e)) } @@ -156,7 +156,7 @@ class Multi { // Either undefined or an array. Fail hard if it's not an array if (args) { // Legacy support for passing in an array of arguments - for (let i = 0; i < args.length; i++) { + for (var i = 0; i < args.length; i++) { const command = args[i][0] const tmpArgs = args[i].slice(1) if (Array.isArray(command)) { diff --git a/lib/utils.js b/lib/utils.js index a422993fb5..90d43d6742 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -62,7 +62,7 @@ function clone (obj) { var copy if (Array.isArray(obj)) { copy = new Array(obj.length) - for (let i = 0; i < obj.length; i++) { + for (var i = 0; i < obj.length; i++) { copy[i] = clone(obj[i]) } return copy @@ -70,7 +70,7 @@ function clone (obj) { if (Object.prototype.toString.call(obj) === '[object Object]') { copy = {} const elements = Object.keys(obj) - for (let elem = elements.pop(); elem !== undefined; elem = elements.pop()) { + for (var elem = elements.pop(); elem !== undefined; elem = elements.pop()) { copy[elem] = clone(obj[elem]) } return copy