[Groonga-commit] groonga/express-kotoumi [master] Rename variables named "command" to "name" or "commandName" for readability

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Feb 7 17:33:30 JST 2013


YUKI Hiroshi	2013-02-07 17:33:30 +0900 (Thu, 07 Feb 2013)

  New Revision: ab729938153bcc2a7b185b6a37006e70816570f7
  https://github.com/groonga/express-kotoumi/commit/ab729938153bcc2a7b185b6a37006e70816570f7

  Log:
    Rename variables named "command" to "name" or "commandName" for readability

  Modified files:
    lib/frontend/rest-adaptor.js
    lib/frontend/socket.io-adaptor.js

  Modified: lib/frontend/rest-adaptor.js (+12 -12)
===================================================================
--- lib/frontend/rest-adaptor.js    2013-02-07 17:26:53 +0900 (4eb8511)
+++ lib/frontend/rest-adaptor.js    2013-02-07 17:33:30 +0900 (a486382)
@@ -4,17 +4,17 @@ var defaultCommands = require('./default-commands/rest');
 function createHandler(params) {
   params = params || {};
   var connection = params.connection;
-  var command = params.command;
+  var commandName = params.name;
   var definition = params.definition;
 
   if (!definition.toBackend)
-    throw new Error('no filter for the backend: ' + command);
+    throw new Error('no filter for the backend: ' + commandName);
 
   return (function(request, response) {
     var message = definition.toBackend(request);
     var timeout = message.timeout || null;
     connection.emitMessage(
-      command,
+      commandName,
       message,
       function(error, responseMessage) {
         if (error) {
@@ -58,27 +58,27 @@ exports.register = function(application, params) {
   var commandSets = [defaultCommands].concat(params.plugins || []);
   var unifiedCommandSet = {};
   commandSets.forEach(function(commandSet) {
-    Object.keys(commandSet).forEach(function(command) {
-      var definition = commandSet[command];
+    Object.keys(commandSet).forEach(function(commandName) {
+      var definition = commandSet[commandName];
       if (!model.isA(definition, model.REST))
         return;
-      unifiedCommandSet[command] = definition;
+      unifiedCommandSet[commandName] = definition;
     });
   });
 
   var registeredCommands = [];
-  Object.keys(unifiedCommandSet).forEach(function(command) {
-    var definition = unifiedCommandSet[command];
+  Object.keys(unifiedCommandSet).forEach(function(commandName) {
+    var definition = unifiedCommandSet[commandName];
     if (!model.isA(definition, model.REST))
       return;
     var method = getRegisterationMethod(definition.method);
     var handler = createHandler({
-      connection: connection,
-      command:    definition.command || command,
-      definition: definition
+      connection:  connection,
+      name:        definition.command || commandName,
+      definition:  definition
     });
     application[method](prefix + definition.path, handler);
-    registeredCommands.push({ command:    command,
+    registeredCommands.push({ name:       commandName,
                               definition: definition,
                               handler:    handler });
   });

  Modified: lib/frontend/socket.io-adaptor.js (+8 -8)
===================================================================
--- lib/frontend/socket.io-adaptor.js    2013-02-07 17:26:53 +0900 (0bfece8)
+++ lib/frontend/socket.io-adaptor.js    2013-02-07 17:33:30 +0900 (ab0ca02)
@@ -81,20 +81,20 @@ exports.register = function(application, server, params) {
   var commandSets = [defaultCommands].concat(params.plugins || []);
   var unifiedCommandSet = {};
   commandSets.forEach(function(commandSet) {
-    Object.keys(commandSet).forEach(function(command) {
-      var definition = commandSet[command];
+    Object.keys(commandSet).forEach(function(commandName) {
+      var definition = commandSet[commandName];
       if (!model.isA(definition, model.SocketCommand))
         return;
-      unifiedCommandSet[command] = definition;
+      unifiedCommandSet[commandName] = definition;
     });
   });
 
   var registeredCommands = [];
-  Object.keys(unifiedCommandSet).forEach(function(command) {
-    var definition = unifiedCommandSet[command];
+  Object.keys(unifiedCommandSet).forEach(function(commandName) {
+    var definition = unifiedCommandSet[commandName];
     if (!model.isA(definition, model.SocketCommand))
       return;
-    registeredCommands.push({ command:    command,
+    registeredCommands.push({ name:       commandName,
                               definition: definition });
   });
 
@@ -104,8 +104,8 @@ exports.register = function(application, server, params) {
 
     var messageHandlers = [];
     registeredCommands.forEach(function(command) {
-      socket.on(command.command,
-                createClientMessageHandler(command.command, socket));
+      socket.on(command.name,
+                createClientMessageHandler(command.name, socket));
 
       if (model.isA(command.definition, model.PublishSubscribe)) {
         var publishedMessageHandler = createPublishedMessageHandler(socket);
-------------- next part --------------
HTML����������������������������...
Descargar 



More information about the Groonga-commit mailing list
Back to archive index