From a6053c510a44b5be9108d7d7a78218b98e524326 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 5 May 2017 18:50:47 +0200 Subject: [PATCH] chore: remove obsolete feature detection and only override name if not set / different --- lib/commands.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) 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 });