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

Merge pull request #1076 from danmactough/use-safe-function-names

Ensure synthetic function names conform to naming requirements
This commit is contained in:
Ruben Bridgewater
2016-06-02 00:29:54 +02:00

View File

@@ -21,6 +21,7 @@ var changeFunctionName = (function () {
// that provided a functionality to add new commands to the client
commands.list.forEach(function (command) {
var commandName = command.replace(/(?:^([0-9])|[^a-zA-Z0-9_$])/g, '_$1');
// Do not override existing functions
if (!RedisClient.prototype[command]) {
@@ -59,7 +60,7 @@ commands.list.forEach(function (command) {
};
if (changeFunctionName) {
Object.defineProperty(RedisClient.prototype[command], 'name', {
value: command
value: commandName
});
}
}
@@ -102,7 +103,7 @@ commands.list.forEach(function (command) {
};
if (changeFunctionName) {
Object.defineProperty(Multi.prototype[command], 'name', {
value: command
value: commandName
});
}
}