You've already forked node-redis
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:
@@ -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
|
||||
});
|
||||
|
Reference in New Issue
Block a user