Browse Source

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

Ensure synthetic function names conform to naming requirements
master
Ruben Bridgewater 9 years ago
parent
commit
1487760ffd
  1. 5
      lib/commands.js

5
lib/commands.js

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

Loading…
Cancel
Save