MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / loadModules

Function loadModules

web/static/bower_components/angular/angular.js:4371–4418  ·  view source on GitHub ↗
(modulesToLoad)

Source from the content-addressed store, hash-verified

4369 // Module Loading
4370 ////////////////////////////////////
4371 function loadModules(modulesToLoad) {
4372 assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), 'modulesToLoad', 'not an array');
4373 var runBlocks = [], moduleFn;
4374 forEach(modulesToLoad, function(module) {
4375 if (loadedModules.get(module)) return;
4376 loadedModules.put(module, true);
4377
4378 function runInvokeQueue(queue) {
4379 var i, ii;
4380 for (i = 0, ii = queue.length; i < ii; i++) {
4381 var invokeArgs = queue[i],
4382 provider = providerInjector.get(invokeArgs[0]);
4383
4384 provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
4385 }
4386 }
4387
4388 try {
4389 if (isString(module)) {
4390 moduleFn = angularModule(module);
4391 runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
4392 runInvokeQueue(moduleFn._invokeQueue);
4393 runInvokeQueue(moduleFn._configBlocks);
4394 } else if (isFunction(module)) {
4395 runBlocks.push(providerInjector.invoke(module));
4396 } else if (isArray(module)) {
4397 runBlocks.push(providerInjector.invoke(module));
4398 } else {
4399 assertArgFn(module, 'module');
4400 }
4401 } catch (e) {
4402 if (isArray(module)) {
4403 module = module[module.length - 1];
4404 }
4405 if (e.message && e.stack && e.stack.indexOf(e.message) == -1) {
4406 // Safari & FF's stack traces don't contain error.message content
4407 // unlike those of Chrome and IE
4408 // So if stack doesn't contain message, we create a new string that contains both.
4409 // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
4410 /* jshint -W022 */
4411 e = e.message + '\n' + e.stack;
4412 }
4413 throw $injectorMinErr('modulerr', "Failed to instantiate module {0} due to:\n{1}",
4414 module, e.stack || e.message || e);
4415 }
4416 });
4417 return runBlocks;
4418 }
4419
4420 ////////////////////////////////////
4421 // internal Injector

Callers 1

createInjectorFunction · 0.85

Calls 8

assertArgFunction · 0.85
isUndefinedFunction · 0.85
forEachFunction · 0.85
isStringFunction · 0.85
runInvokeQueueFunction · 0.85
isFunctionFunction · 0.85
assertArgFnFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected