MCPcopy Create free account
hub / github.com/aosabook/500lines / loadModules

Function loadModules

spreadsheet/code/lib/angular.js:4046–4092  ·  view source on GitHub ↗
(modulesToLoad)

Source from the content-addressed store, hash-verified

4044 // Module Loading
4045 ////////////////////////////////////
4046 function loadModules(modulesToLoad){
4047 var runBlocks = [], moduleFn;
4048 forEach(modulesToLoad, function(module) {
4049 if (loadedModules.get(module)) return;
4050 loadedModules.put(module, true);
4051
4052 function runInvokeQueue(queue) {
4053 var i, ii;
4054 for(i = 0, ii = queue.length; i < ii; i++) {
4055 var invokeArgs = queue[i],
4056 provider = providerInjector.get(invokeArgs[0]);
4057
4058 provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
4059 }
4060 }
4061
4062 try {
4063 if (isString(module)) {
4064 moduleFn = angularModule(module);
4065 runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
4066 runInvokeQueue(moduleFn._invokeQueue);
4067 runInvokeQueue(moduleFn._configBlocks);
4068 } else if (isFunction(module)) {
4069 runBlocks.push(providerInjector.invoke(module));
4070 } else if (isArray(module)) {
4071 runBlocks.push(providerInjector.invoke(module));
4072 } else {
4073 assertArgFn(module, 'module');
4074 }
4075 } catch (e) {
4076 if (isArray(module)) {
4077 module = module[module.length - 1];
4078 }
4079 if (e.message && e.stack && e.stack.indexOf(e.message) == -1) {
4080 // Safari & FF's stack traces don't contain error.message content
4081 // unlike those of Chrome and IE
4082 // So if stack doesn't contain message, we create a new string that contains both.
4083 // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
4084 /* jshint -W022 */
4085 e = e.message + '\n' + e.stack;
4086 }
4087 throw $injectorMinErr('modulerr', "Failed to instantiate module {0} due to:\n{1}",
4088 module, e.stack || e.message || e);
4089 }
4090 });
4091 return runBlocks;
4092 }
4093
4094 ////////////////////////////////////
4095 // internal Injector

Callers 1

createInjectorFunction · 0.85

Calls 8

forEachFunction · 0.85
isStringFunction · 0.85
runInvokeQueueFunction · 0.85
isFunctionFunction · 0.85
assertArgFnFunction · 0.85
invokeMethod · 0.80
getMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected