From 11735099d60a073dff1c3511f2cdbc5814a019f8 Mon Sep 17 00:00:00 2001 From: vitaliylag Date: Thu, 28 May 2015 14:50:46 +0300 Subject: [PATCH] Update index.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was almost bug: imagine args is array but callback is not defined - in this case all args (that is consists of one array) are packing to new array. That mean we get this: this.send_command(command, [[...]]). It doesn't make any sense. After I fix it we get this: this.send_command(command, [...], undefined). It's really ok because if we call for example client.hget("test", "aaa") we actually do the same: this.send_command("hget", ["test", "aaa"], undefined). No different from this.send_command(command, [...], undefined). By the way, «this.send_command(command, [[...]])» could be a bug. Try to call client.eval(["return 1", 0]) and you should get throw because "eval" required 2 param, but program thinks it's only one param: ["return 1", 0] (at the beginning it was [["return 1", 0]]). There's only one reason why you don't get throw - RedisClient.prototype.eval is overridden for some optimizations, lucky. But that doesn't mean everything is ok. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7ec7477..c5b85b4 100644 --- a/index.js +++ b/index.js @@ -985,7 +985,7 @@ commands.forEach(function (fullCommand) { var command = fullCommand.split(' ')[0]; RedisClient.prototype[command] = function (args, callback) { - if (Array.isArray(args) && typeof callback === "function") { + if (Array.isArray(args)) { return this.send_command(command, args, callback); } else { return this.send_command(command, to_array(arguments));