YUKI Hiroshi
null+****@clear*****
Mon Dec 16 16:03:09 JST 2013
YUKI Hiroshi 2013-12-16 16:03:09 +0900 (Mon, 16 Dec 2013) New Revision: 29d9f3e80bab2a974d8e2ad3c72e6042c589e622 https://github.com/droonga/express-droonga/commit/29d9f3e80bab2a974d8e2ad3c72e6042c589e622 Message: Don't define same property twice Modified files: lib/adapter/command.js Modified: lib/adapter/command.js (+25 -9) =================================================================== --- lib/adapter/command.js 2013-12-16 15:59:08 +0900 (691d674) +++ lib/adapter/command.js 2013-12-16 16:03:09 +0900 (cb09541) @@ -7,7 +7,9 @@ function Command(options) { } Command.commandTypes = []; Command.extend = function(targetClass) { - targetClass.commandTypes = targetClass.commandTypes || [Command]; + if (targetClass.commandTypes) + return; + targetClass.commandTypes = [this]; targetClass.prototype.isInstanceOf = function(commandType) { return ( commandType && @@ -33,8 +35,10 @@ function RequestResponse(options) { Command.apply(this, arguments); } RequestResponse.extend = function(targetClass) { + if (targetClass.commandTypes.indexOf(this)) + return; Command.extend(targetClass); - targetClass.commandTypes.push(RequestResponse); + targetClass.commandTypes.push(this); Object.defineProperty(targetClass.prototype, 'onRequest', { get: function() { return this._options.onRequest; } }); @@ -50,8 +54,10 @@ function PublishSubscribe(options) { Command.apply(this, arguments); } PublishSubscribe.extend = function(targetClass) { + if (targetClass.commandTypes.indexOf(this)) + return; Command.extend(targetClass); - targetClass.commandTypes.push(PublishSubscribe); + targetClass.commandTypes.push(this); Object.defineProperty(targetClass.prototype, 'onSubscribe', { get: function() { return this._options.onSubscribe; } }); @@ -80,8 +86,10 @@ function HTTPCommand(options) { Command.apply(this, arguments); } HTTPCommand.extend = function(targetClass) { + if (targetClass.commandTypes.indexOf(this)) + return; Command.extend(targetClass); - targetClass.commandTypes.push(HTTPCommand); + targetClass.commandTypes.push(this); Object.defineProperty(targetClass.prototype, 'path', { get: function() { return this._options.path; } }); @@ -98,9 +106,11 @@ function HTTPRequestResponse(options) { Command.apply(this, arguments); } HTTPRequestResponse.extend = function(targetClass) { - HTTPCommand.extend(targetClass); + if (targetClass.commandTypes.indexOf(this)) + return; + Command.extend(targetClass); RequestResponse.extend(targetClass); - targetClass.commandTypes.push(HTTPRequestResponse); + targetClass.commandTypes.push(this); }; HTTPRequestResponse.extend(HTTPRequestResponse); exports.HTTPRequestResponse = HTTPRequestResponse; @@ -111,8 +121,10 @@ function SocketCommand() { Command.apply(this, arguments); } SocketCommand.extend = function(targetClass) { + if (targetClass.commandTypes.indexOf(this)) + return; Command.extend(targetClass); - targetClass.commandTypes.push(SocketCommand); + targetClass.commandTypes.push(this); }; SocketCommand.extend(SocketCommand); exports.SocketCommand = SocketCommand; @@ -122,9 +134,11 @@ function SocketRequestResponse(options) { Command.apply(this, arguments); } SocketRequestResponse.extend = function(targetClass) { + if (targetClass.commandTypes.indexOf(this)) + return; Command.extend(targetClass); RequestResponse.extend(targetClass); - targetClass.commandTypes.push(SocketRequestResponse); + targetClass.commandTypes.push(this); }; SocketRequestResponse.extend(SocketRequestResponse); exports.SocketRequestResponse = SocketRequestResponse; @@ -134,9 +148,11 @@ function SocketPublishSubscribe(options) { Command.apply(this, arguments); } SocketPublishSubscribe.extend = function(targetClass) { + if (targetClass.commandTypes.indexOf(this)) + return; Command.extend(targetClass); PublishSubscribe.extend(targetClass); - targetClass.commandTypes.push(SocketPublishSubscribe); + targetClass.commandTypes.push(this); }; SocketPublishSubscribe.extend(SocketPublishSubscribe); exports.SocketPublishSubscribe = SocketPublishSubscribe; -------------- next part -------------- HTML����������������������������...Download