1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00

chore: remove obsolete feature detection and only override name if not set / different

This commit is contained in:
Ruben Bridgewater
2017-05-05 18:50:47 +02:00
parent 086c90d938
commit a6053c510a

View File

@@ -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
});