Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Explode first arg if array. Allows mget(['a','b'],...)

  • Loading branch information...
commit 22e63abcff940f3409d6d7ef3a07e3d7739f9709 1 parent 95c5c78
@fictorial fictorial authored
Showing with 15 additions and 3 deletions.
  1. +3 −0  lib/redis-client.js
  2. +3 −2 package.json
  3. +1 −1  seed.yml
  4. +8 −0 test/test.js
View
3  lib/redis-client.js
@@ -748,6 +748,9 @@ Client.prototype.sendCommand = function () {
commands.forEach(function (commandName) {
Client.prototype[commandName] = function () {
var args = Array.prototype.slice.call(arguments);
+ // [[1,2,3],function(){}] => [1,2,3,function(){}]
+ if (args.length > 0 && Array.isArray(args[0]))
+ args = args.shift().concat(args);
args.unshift(commandName);
this.sendCommand.apply(this, args);
};
View
5 package.json
@@ -1,7 +1,7 @@
{
"name": "redis-node-client",
"description": "Redis client for Node.js",
- "version": "0.3.2",
+ "version": "0.3.3",
"keywords": [ "redis", "node", "client" ],
"author": "Brian Hammond <brian@fictorial.com>",
"contributors": [
@@ -16,7 +16,8 @@
{ "name": "technoweenie (rick)", "web": "http://techno-weenie.net" },
{ "name": "Donovan Hide", "web": "http://availableimagination.com" },
{ "name": "Philip Hofstetter", "web": "http://www.gnegg.ch/" },
- { "name": "Chris Winberry", "web": "http://tautologistics.com/" }
+ { "name": "Chris Winberry", "web": "http://tautologistics.com/" },
+ { "name": "Brian McKinney", "web": "http://twitter.com/tritonrc" }
],
"licenses": [ "MIT" ],
"repositories": {
View
2  seed.yml
@@ -2,5 +2,5 @@
name: redis-client
description: A Redis client
tags: redis
- version: 0.3.2
+ version: 0.3.3
View
8 test/test.js
@@ -337,6 +337,14 @@ function testMGET() {
checkEqual(values[0], 'bar', "testMGET");
checkEqual(values[1], 'buz', "testMGET");
});
+
+ // Accept an Array for the keys to MGET as well.
+
+ client.mget(['foo', 'baz'], function (err, values) {
+ if (err) assert.fail(err, "testMGET");
+ checkEqual(values[0], 'bar', "testMGET");
+ checkEqual(values[1], 'buz', "testMGET");
+ });
}
function testGETSET() {
Please sign in to comment.
Something went wrong with that request. Please try again.