diff --git a/lib/commands.js b/lib/commands.js index c488c9fdd5..7ccfcc8309 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -4,22 +4,9 @@ var commands = require('redis-commands'); var Multi = require('./multi'); var RedisClient = require('../').RedisClient; var Command = require('./command'); -// Feature detect if a function may change it's name -var changeFunctionName = (function () { - var fn = function abc () {}; - try { - Object.defineProperty(fn, 'name', { - value: 'foobar' - }); - return true; - } catch (e) { - return false; - } -}()); // TODO: Rewrite this including the individual commands into a Commands class // that provided a functionality to add new commands to the client - commands.list.forEach(function (command) { // Some rare Redis commands use special characters in their command name @@ -61,7 +48,7 @@ commands.list.forEach(function (command) { } return this.internalSendCommand(new Command(command, arr, callback)); }; - if (changeFunctionName) { + if (RedisClient.prototype[command] !== commandName) { Object.defineProperty(RedisClient.prototype[command], 'name', { value: commandName }); @@ -104,7 +91,7 @@ commands.list.forEach(function (command) { this.queue.push(new Command(command, arr, callback)); return this; }; - if (changeFunctionName) { + if (Multi.prototype[command] !== commandName) { Object.defineProperty(Multi.prototype[command], 'name', { value: commandName });