1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

fixes #218 by expanding last argument array only for sadd command

Also adds a test that uses SADD in caps. Nicely enough, this makes
multi_bench.js run just a tiny bit faster :)

Signed-off-by: DTrejo <david.trejo@voxer.com>
This commit is contained in:
Martín Ciparelli
2012-08-17 15:23:25 -03:00
committed by DTrejo
parent c8103928b4
commit 124ea082b9
2 changed files with 13 additions and 7 deletions

View File

@@ -676,12 +676,11 @@ RedisClient.prototype.send_command = function (command, args, callback) {
throw new Error("send_command: second argument must be an array");
}
// if the last argument is an array, expand it out. This allows commands like this:
// client.command(arg1, [arg2, arg3, arg4], cb);
// and converts to:
// client.command(arg1, arg2, arg3, arg4, cb);
// which is convenient for some things like sadd
if (args.length > 0 && Array.isArray(args[args.length - 1])) {
// if the last argument is an array and command is sadd, expand it out:
// client.sadd(arg1, [arg2, arg3, arg4], cb);
// converts to:
// client.sadd(arg1, arg2, arg3, arg4, cb);
if ((command === 'sadd' || command === 'SADD') && args.length > 0 && Array.isArray(args[args.length - 1])) {
args = args.slice(0, -1).concat(args[args.length - 1]);
}