Skip to content

Commit

Permalink
Explode first arg if array. Allows mget(['a','b'],...)
Browse files Browse the repository at this point in the history
  • Loading branch information
fictorial committed May 4, 2010
1 parent 95c5c78 commit 22e63ab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/redis-client.js
Expand Up @@ -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);
};
Expand Down
5 changes: 3 additions & 2 deletions 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": [
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion seed.yml
Expand Up @@ -2,5 +2,5 @@
name: redis-client
description: A Redis client
tags: redis
version: 0.3.2
version: 0.3.3

8 changes: 8 additions & 0 deletions test/test.js
Expand Up @@ -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() {
Expand Down

0 comments on commit 22e63ab

Please sign in to comment.