Load configuration for every module
@return {Promise<void>}
167565
async function loadModulesConfig()
{
    if(!modulesLoaded)
    {
		for (let i = 0; i < modules.length; i++) {
			await applyBotDataSource(modules[i]);
        }
        
        modulesLoaded = true;
    }
}
1181536
function load() {
  if (!loaded) {
    var addons = [], skipped = [];

    // load addon modules
    api.require.forEach(['socketstream-*','socketstream.*'],function(mod,id) {
      if (typeof mod === 'function') {
        try {
          mod(api);
          addons.push(id);
        } catch(ex) {
          debug('Failed to load '+id+'. ',ex);
        }
      } else {
        skipped.push(id);
      }
    });
    debug('Addons: '+
      addons.length? addons.join(' + ') + ' Loaded. ':' None. '+
      skipped.length? skipped.join(' + ') + ' Skipped. ':'');

    // load assets in cache
    http.load();

    // Load Client Asset Manager
    client.load();

    // Load internal and project responders
    api.server.responders = exports.responders.load();

    api.server.eventTransport = publish.transport.load();

    // Extend the internal API with a publish object you can call from your own server-side code
    api.publish = publish.api(api.server.eventTransport);

    // Bind responders to websocket
    ws.load(api.server.responders, api.server.eventTransport);

    debug('API loaded.');
  }
  loaded = true;
}
1014349
function loadApis() {
  // Shortcut if apis already have been loaded
  if (apis !== undefined) {
    return Promise.resolve(apis);
  }

  const apiSpecsPath = path.join(process.cwd(), plugin.config.apisPath);

  // This event allows to inject code before loading all APIs
  return plugin.myrmex.fire('beforeApisLoad')
  .then(() => {
    // Retrieve configuration path of all API specifications
    return Promise.promisify(fs.readdir)(apiSpecsPath);
  })
  .then(subdirs => {
    // Load all the API specifications
    const apiPromises = [];
    _.forEach(subdirs, (subdir) => {
      const apiSpecPath = path.join(apiSpecsPath, subdir, 'spec');
      // subdir is the identifier of the API, so we pass it as the second argument
      apiPromises.push(loadApi(apiSpecPath, subdir));
    });
    return Promise.all(apiPromises);
  })
  .then(apis => {
    // This event allows to inject code to add or delete or alter API specifications
    return plugin.myrmex.fire('afterApisLoad', apis);
  })
  .spread(loadedApis => {
    apis = loadedApis;
    return Promise.resolve(apis);
  })
  .catch(e => {
    if (e.code === 'ENOENT' && path.basename(e.path) === path.basename(plugin.config.apisPath)) {
      return Promise.resolve([]);
    }
    return Promise.reject(e);
  });
}
38853
function loadAll( state, resourcePath ) {
	var loadActions = [ loadResources( state, resourcePath ) ] || [];
	if ( state.config.modules ) {
		_.each( state.config.modules, function( mod ) {
			var modPath;
			if ( /[\/]/.test( mod ) ) {
				modPath = require.resolve( path.resolve( process.cwd(), mod ) );
			} else {
				modPath = require.resolve( mod );
			}
			loadActions.push( loadModule( state, modPath ) );
		} );
	}
	loadActions.push( loadModule( state, './ahResource' ) );
	return when.all( loadActions );
}
249137
function loadAll() {
      var repos = [
        {
          'name'      : 'AngularJS',
          'url'       : 'https://github.com/angular/angular.js',
          'watchers'  : '3,623',
          'forks'     : '16,175',
        },
        {
          'name'      : 'Angular',
          'url'       : 'https://github.com/angular/angular',
          'watchers'  : '469',
          'forks'     : '760',
        },
        {
          'name'      : 'AngularJS Material',
          'url'       : 'https://github.com/angular/material',
          'watchers'  : '727',
          'forks'     : '1,241',
        },
        {
          'name'      : 'Angular Material',
          'url'       : 'https://github.com/angular/material2',
          'watchers'  : '727',
          'forks'     : '1,241',
        },
        {
          'name'      : 'Bower Material',
          'url'       : 'https://github.com/angular/bower-material',
          'watchers'  : '42',
          'forks'     : '84',
        },
        {
          'name'      : 'Material Start',
          'url'       : 'https://github.com/angular/material-start',
          'watchers'  : '81',
          'forks'     : '303',
        }
      ];
      return repos.map(function (repo) {
        repo.value = repo.name.toLowerCase();
        return repo;
      });
    }
601930
function load(mod) {
    if (typeof(mod.factory) === "function") {
      return require(mod.deps, mod.factory);
    }
    return mod.factory;
  }
870316
function resolve() {
    var promises = [];
    var args = flatten(arguments);
    for (var i = 0; i < args.length; i ++) {
      promises.push(Esquire.resolve(args[i], true, true));
    }

    /* Await for resolution of dependencies */
    return Promise.all(promises).then(function(result) {
      var modules = {};
      for (var i = 0; i < result.length; i ++) {
        var resolved = result[i];
        for (var name in resolved) {
          var module = resolved[name];
          if (module.$$dynamic) continue;
          modules[name] = resolved[name];
        }
      }
      return modules;
    });
  }
778201
function loadPolicies() {
  const policyConfigsPath = path.join(process.cwd(), plugin.config.policiesPath);

  // This event allows to inject code before loading all APIs
  return plugin.myrmex.fire('beforePoliciesLoad')
  .then(() => {
    // Retrieve configuration path of all API specifications
    return fs.readdirAsync(policyConfigsPath);
  })
  .then(policyConfigFiles => {
    // Load all the policy configurations
    const policyPromises = [];
    _.forEach(policyConfigFiles, (filename) => {
      const policyConfigPath = path.join(policyConfigsPath, filename);
      const policyName = path.parse(filename).name;
      policyPromises.push(loadPolicy(policyConfigPath, policyName));
    });
    return Promise.all(policyPromises);
  })
  .then(policies => {
    // This event allows to inject code to add or delete or alter policy configurations
    return plugin.myrmex.fire('afterPoliciesLoad', policies);
  })
  .spread(policies => {
    return Promise.resolve(policies);
  })
  .catch(e => {
    if (e.code === 'ENOENT' && path.basename(e.path) === 'policies') {
      return Promise.resolve([]);
    }
    return Promise.reject(e);
  });
}
318320
function createModuleConfig(loader) {
	var tmp = require("tmp");
	var config = {};
	var virtualModules = loader.virtualModules || {};
	for(var moduleName in virtualModules) {
		var filename = tmp.fileSync().name;
		var source = virtualModules[moduleName];
		fs.writeFileSync(filename, source, "utf8");

		var paths = config.paths = config.paths || {};
		paths[moduleName] = "file:"+filename;
	}
	return config;
}
454441
function loadModule(requires, fullModuleName, loadedModuleData) {
    return new Promise(function(resolve, reject) {
      // First off, try and find this module using callProcessor
      Espruino.callProcessor("getModule",
        { moduleName:fullModuleName, moduleCode:undefined, isMinified:false },
        function(data) {
          if (data.moduleCode===undefined) {
            Espruino.Core.Notifications.warning("Module "+fullModuleName+" not found");
            return resolve();
          }

          // great! it found something. Use it.
          moduleLoaded(resolve, requires, fullModuleName, data.moduleCode, loadedModuleData, data.isMinified);
        });
    });
  }
1229599
public function loadConfig()
    {
        parent::loadConfig();
        foreach(Config::get('@' . $this->moduleName . '.configs', []) as $name => $fileName)
        {
            Config::addConfig($name, include $fileName);
        }
    }
1168895
function loadConfig() {
  var root = process.cwd()
    , config = readConfig(path.join(root, '_config.json'));
  config.root = root;
  return config;
}
423129
function(parentModule, id, callback) {

  // Try to load the module.
  return Promise.try(function() {
    return parentModule.require(id);
  })
  // Ignore module not found errors, and decorate all others.
  .catch(function(err) {
    if (err.code !== 'MODULE_NOT_FOUND') {
      throw new KboxRequireError(id, err);
    }
  })
  // Return.
  .nodeify(callback);

}
542312
async function(dependencies, relative_path_root, search_for_dependencies){ // load dependencies for synchronous injected require types
        /*
            normalize input
        */
        if(typeof dependencies == "undefined") dependencies = [];

        /*
            define dependency options to be used for caching the modules
                - pass relative path root
        */
        var dependency_options = {
            relative_path_root:relative_path_root, // pass relative path root
            search_for_dependencies:search_for_dependencies, // NOTE: this will always be : true. We inject it though to make it clear why that is the case.
                                                             //     and do not worry - if a future module states that it should search for its dependencies, we still will, as the option will be overwritten by that modules settings
        };

        /*
            create promises to cache each
        */
        var promises_to_cache_each = [];
        for(var i = 0; i < dependencies.length; i++){ // promise to load each dependency
            let dependency = dependencies[i]; //
            var this_promise = window.clientside_require.asynchronous_require(dependency, dependency_options) // call async require to cache the module
                .catch((err)=>{
                    console.warn("could not load dependency " + dependency + " found in " + relative_path_root);
                })
            promises_to_cache_each.push(this_promise);
        }

        /*
            resolve only after all are loaded
        */
        return Promise.all(promises_to_cache_each); // note that we do not await each promise individually so that multiple dependencies can load at a time
    }
537490
public static function initModules() {
        $cfg = ServiceContainer::get('config');
        $moduleList = $cfg->getConfigData('modules');
        if (count($moduleList) > 0) {
            foreach ($moduleList as $moduleName) {
                self::loadModule($moduleName);
            }
        }
    }
1020873
function(map, callback) {

            // Walk through all modules in parallel
            async.map(map, function(module, callback) {

                logger.info('Loading ' + (module.name).blue + ' module');

                // Walk through all possible controllers of the module
                async.map(module.paths, function(path, callback) {

                    self.loadController(
                        path,
                        basename(path.replace(/\.js$/g, '')),
                        module.name,
                        callback
                    );

                }, function(err, controllers) {
                    module.controllers = controllers;
                    callback(err, module);
                });

            }, callback);
        }
1220063
function(context, pkg){
		var deps = crawl.getDependencyMap(context.loader, pkg, true);

		var pluginsPromise = crawl.loadPlugins(context, pkg, true, deps, true);
		var stealPromise = crawl.loadSteal(context, pkg, true, deps);

		return Promise.all([pluginsPromise, stealPromise]);
	}