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

Function loadModules

lib/test/angular/1.7.0/angular.js:4969–5017  ·  view source on GitHub ↗
(modulesToLoad)

Source from the content-addressed store, hash-verified

4967 // Module Loading
4968 ////////////////////////////////////
4969 function loadModules(modulesToLoad) {
4970 assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), 'modulesToLoad', 'not an array');
4971 var runBlocks = [], moduleFn;
4972 forEach(modulesToLoad, function(module) {
4973 if (loadedModules.get(module)) return;
4974 loadedModules.set(module, true);
4975
4976 function runInvokeQueue(queue) {
4977 var i, ii;
4978 for (i = 0, ii = queue.length; i < ii; i++) {
4979 var invokeArgs = queue[i],
4980 provider = providerInjector.get(invokeArgs[0]);
4981
4982 provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
4983 }
4984 }
4985
4986 try {
4987 if (isString(module)) {
4988 moduleFn = angularModule(module);
4989 instanceInjector.modules[module] = moduleFn;
4990 runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
4991 runInvokeQueue(moduleFn._invokeQueue);
4992 runInvokeQueue(moduleFn._configBlocks);
4993 } else if (isFunction(module)) {
4994 runBlocks.push(providerInjector.invoke(module));
4995 } else if (isArray(module)) {
4996 runBlocks.push(providerInjector.invoke(module));
4997 } else {
4998 assertArgFn(module, 'module');
4999 }
5000 } catch (e) {
5001 if (isArray(module)) {
5002 module = module[module.length - 1];
5003 }
5004 if (e.message && e.stack && e.stack.indexOf(e.message) === -1) {
5005 // Safari & FF's stack traces don't contain error.message content
5006 // unlike those of Chrome and IE
5007 // So if stack doesn't contain message, we create a new string that contains both.
5008 // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
5009 // eslint-disable-next-line no-ex-assign
5010 e = e.message + '\n' + e.stack;
5011 }
5012 throw $injectorMinErr('modulerr', 'Failed to instantiate module {0} due to:\n{1}',
5013 module, e.stack || e.message || e);
5014 }
5015 });
5016 return runBlocks;
5017 }
5018
5019 ////////////////////////////////////
5020 // internal Injector

Callers 1

createInjectorFunction · 0.70

Calls 8

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

Tested by

no test coverage detected