From 32172cd29120811b4e3c899a3df00ff40bea5297 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 21 Jan 2016 22:38:05 +0100 Subject: [PATCH] Use instanceof Array instead of Array.isArray The reply is being done with a regular array and therefor will be the same array instance --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 481fd1f0b1..7b3db9198b 100644 --- a/index.js +++ b/index.js @@ -535,8 +535,6 @@ RedisClient.prototype.drain = function () { RedisClient.prototype.emit_idle = function (queue_len) { if (this.pub_sub_mode === false && queue_len === 0) { - // Free the queue capacity memory by using a new queue - this.command_queue = new Queue(); this.emit('idle'); } }; @@ -547,7 +545,7 @@ RedisClient.prototype.return_reply = function (reply) { // If the 'reply' here is actually a message received asynchronously due to a // pubsub subscription, don't pop the command queue as we'll only be consuming // the head command prematurely. - if (this.pub_sub_mode && Array.isArray(reply) && reply[0]) { + if (this.pub_sub_mode && reply instanceof Array && reply[0]) { type = reply[0].toString(); } @@ -571,12 +569,13 @@ RedisClient.prototype.return_reply = function (reply) { debug('No callback for reply'); } } else if (this.pub_sub_mode || command_obj && command_obj.sub_command) { - if (Array.isArray(reply)) { + if (reply instanceof Array) { if ((!command_obj || command_obj.buffer_args === false) && !this.options.return_buffers) { reply = utils.reply_to_strings(reply); } type = reply[0].toString(); + // TODO: Add buffer emiters (we have to get all pubsub messages as buffers back in that case) if (type === 'message') { this.emit('message', reply[1], reply[2]); // channel, message } else if (type === 'pmessage') {