You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
A function name is only configurable from v8 >= v.4.3
This commit is contained in:
@@ -10,7 +10,7 @@ Features
|
||||
- Updated [redis-parser](https://github.com/NodeRedis/redis-parser) dependency ([changelog](https://github.com/NodeRedis/redis-parser/releases/tag/v.2.0.0))
|
||||
- The JS parser is from now on the new default as it is a lot faster than the hiredis parser
|
||||
- This is no BC as there is no changed behavior for the user at all but just a performance improvement. Explicitly requireing the Hiredis parser is still possible.
|
||||
- Added name property to all Redis functions
|
||||
- Added name property to all Redis functions (Node.js >= 4.0)
|
||||
|
||||
Bugfixes
|
||||
|
||||
|
@@ -4,6 +4,18 @@ 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 invidual commands into a Commands class
|
||||
// that provided a functionality to add new commands to the client
|
||||
@@ -45,9 +57,11 @@ commands.list.forEach(function (command) {
|
||||
}
|
||||
return this.internal_send_command(new Command(command, arr, callback));
|
||||
};
|
||||
Object.defineProperty(RedisClient.prototype[command], 'name', {
|
||||
value: command
|
||||
});
|
||||
if (changeFunctionName) {
|
||||
Object.defineProperty(RedisClient.prototype[command], 'name', {
|
||||
value: command
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Do not override existing functions
|
||||
@@ -86,8 +100,10 @@ commands.list.forEach(function (command) {
|
||||
this.queue.push(new Command(command, arr, callback));
|
||||
return this;
|
||||
};
|
||||
Object.defineProperty(Multi.prototype[command], 'name', {
|
||||
value: command
|
||||
});
|
||||
if (changeFunctionName) {
|
||||
Object.defineProperty(Multi.prototype[command], 'name', {
|
||||
value: command
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user