From 8cafa5d08e7eb099aa855342ac088100e6f7785e Mon Sep 17 00:00:00 2001 From: simshi Date: Fri, 27 May 2016 20:39:42 +0800 Subject: [PATCH] tolerant undefined callback --- src/setupCommands.js | 4 ++++ test/miscCommands.js | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/setupCommands.js b/src/setupCommands.js index ab91807..64a12e6 100644 --- a/src/setupCommands.js +++ b/src/setupCommands.js @@ -12,6 +12,10 @@ module.exports = function(Class) { args[i] = arguments[i]; } + if (args.length > 0 && typeof args[args.length - 1] === 'undefined') { + args.pop(); + } + this[fn](cmd, conf, args); return this; }; diff --git a/test/miscCommands.js b/test/miscCommands.js index e0a2681..11247cd 100644 --- a/test/miscCommands.js +++ b/test/miscCommands.js @@ -1,6 +1,6 @@ 'use strict'; // not really tests but being used to ensure things are working -var RedisClustr = require('../src/redisClustr'); +var RedisClustr = require('../src/RedisClustr'); var c = new RedisClustr({ servers: [ @@ -32,6 +32,18 @@ c.eval('redis.call("set", KEYS[1], ARGV[1]); return redis.call("get", KEYS[1]);' console.log('eval', err, resp); }); +function delKey(callback) { + c.del('whateverkey', callback); +} + +delKey(function(err) { + if (err) return console.error('del error', err); + + console.log('del'); +}); + +delKey(); + var todo = [ function(done) { var m = c.multi();