MCPcopy
hub / github.com/angular-ui/ui-router / loadModules

Function loadModules

test/angular/1.5/angular.js:4650–4697  ·  view source on GitHub ↗
(modulesToLoad)

Source from the content-addressed store, hash-verified

4648 // Module Loading
4649 ////////////////////////////////////
4650 function loadModules(modulesToLoad) {
4651 assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), 'modulesToLoad', 'not an array');
4652 var runBlocks = [], moduleFn;
4653 forEach(modulesToLoad, function(module) {
4654 if (loadedModules.get(module)) return;
4655 loadedModules.put(module, true);
4656
4657 function runInvokeQueue(queue) {
4658 var i, ii;
4659 for (i = 0, ii = queue.length; i < ii; i++) {
4660 var invokeArgs = queue[i],
4661 provider = providerInjector.get(invokeArgs[0]);
4662
4663 provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
4664 }
4665 }
4666
4667 try {
4668 if (isString(module)) {
4669 moduleFn = angularModule(module);
4670 runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
4671 runInvokeQueue(moduleFn._invokeQueue);
4672 runInvokeQueue(moduleFn._configBlocks);
4673 } else if (isFunction(module)) {
4674 runBlocks.push(providerInjector.invoke(module));
4675 } else if (isArray(module)) {
4676 runBlocks.push(providerInjector.invoke(module));
4677 } else {
4678 assertArgFn(module, 'module');
4679 }
4680 } catch (e) {
4681 if (isArray(module)) {
4682 module = module[module.length - 1];
4683 }
4684 if (e.message && e.stack && e.stack.indexOf(e.message) === -1) {
4685 // Safari & FF's stack traces don't contain error.message content
4686 // unlike those of Chrome and IE
4687 // So if stack doesn't contain message, we create a new string that contains both.
4688 // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
4689 // eslint-disable-next-line no-ex-assign
4690 e = e.message + '\n' + e.stack;
4691 }
4692 throw $injectorMinErr('modulerr', 'Failed to instantiate module {0} due to:\n{1}',
4693 module, e.stack || e.message || e);
4694 }
4695 });
4696 return runBlocks;
4697 }
4698
4699 ////////////////////////////////////
4700 // internal Injector

Callers 1

createInjectorFunction · 0.70

Calls 8

isArrayFunction · 0.85
assertArgFunction · 0.70
isUndefinedFunction · 0.70
forEachFunction · 0.70
isStringFunction · 0.70
runInvokeQueueFunction · 0.70
isFunctionFunction · 0.70
assertArgFnFunction · 0.70

Tested by

no test coverage detected