Libraries/Utilities/MessageQueue.js
/**
   * Converts the old, object-based module structure to the new
   * array-based structure. TODO (t8823865) Removed this
   * function once Android has been updated.
   */
Converts the old, object-based module structure to the new
array-based structure. TODO (t8823865) Removed this
function once Android has been updated.
Converts the old object - based module structure to the new array - based structure . TODO ( t8823865 ) Removed this function once Android has been updated .
_genModulesConfig(modules ) {
    if (Array.isArray(modules)) {
      return modules;
    } else {
      let moduleArray = [];
      let moduleNames = Object.keys(modules);
      for (var i = 0, l = moduleNames.length; i < l; i++) {
        let moduleName = moduleNames[i];
        let moduleConfig = modules[moduleName];
        let module = [moduleName];
        if (moduleConfig.constants) {
          module.push(moduleConfig.constants);
        }
        let methodsConfig = moduleConfig.methods;
        if (methodsConfig) {
          let methods = [];
          let asyncMethods = [];
          let syncHooks = [];
          let methodNames = Object.keys(methodsConfig);
          for (var j = 0, ll = methodNames.length; j < ll; j++) {
            let methodName = methodNames[j];
            let methodConfig = methodsConfig[methodName];
            methods[methodConfig.methodID] = methodName;
            if (methodConfig.type === MethodTypes.remoteAsync) {
              asyncMethods.push(methodConfig.methodID);
            } else if (methodConfig.type === MethodTypes.syncHook) {
              syncHooks.push(methodConfig.methodID);
            }
          }
          if (methods.length) {
            module.push(methods);
            module.push(asyncMethods);
            module.push(syncHooks);
          }
        }
        moduleArray[moduleConfig.moduleID] = module;
      }
      return moduleArray;
    }
  }
_genModulesConfig ( modules ) { if ( Array . isArray ( modules ) ) { return modules ; } else { let moduleArray = [ ] ; let moduleNames = Object . keys ( modules ) ; for ( var i = 0 , l = moduleNames . length ; i < l ; i ++ ) { let moduleName = moduleNames [ i ] ; let moduleConfig = modules [ moduleName ] ; let module = [ moduleName ] ; if ( moduleConfig . constants ) { module . push ( moduleConfig . constants ) ; } let methodsConfig = moduleConfig . methods ; if ( methodsConfig ) { let methods = [ ] ; let asyncMethods = [ ] ; let syncHooks = [ ] ; let methodNames = Object . keys ( methodsConfig ) ; for ( var j = 0 , ll = methodNames . length ; j < ll ; j ++ ) { let methodName = methodNames [ j ] ; let methodConfig = methodsConfig [ methodName ] ; methods [ methodConfig . methodID ] = methodName ; if ( methodConfig . type === MethodTypes . remoteAsync ) { asyncMethods . push ( methodConfig . methodID ) ; } else if ( methodConfig . type === MethodTypes . syncHook ) { syncHooks . push ( methodConfig . methodID ) ; } } if ( methods . length ) { module . push ( methods ) ; module . push ( asyncMethods ) ; module . push ( syncHooks ) ; } } moduleArray [ moduleConfig . moduleID ] = module ; } return moduleArray ; } }
Converts the old, object-based module structure to the new
 array-based structure.
Converts the old object - based module structure to the new array - based structure .
/* array or object */