MCPcopy
hub / github.com/Postcatlab/postcat / loadModules

Function loadModules

src/workbench/browser/src/ng1/lib/angular/angular.js:5192–5241  ·  view source on GitHub ↗
(modulesToLoad)

Source from the content-addressed store, hash-verified

5190 // Module Loading
5191 ////////////////////////////////////
5192 function loadModules(modulesToLoad) {
5193 assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), 'modulesToLoad', 'not an array');
5194 var runBlocks = [],
5195 moduleFn;
5196 forEach(modulesToLoad, function (module) {
5197 if (loadedModules.get(module)) return;
5198 loadedModules.set(module, true);
5199
5200 function runInvokeQueue(queue) {
5201 var i, ii;
5202 for (i = 0, ii = queue.length; i < ii; i++) {
5203 var invokeArgs = queue[i],
5204 provider = providerInjector.get(invokeArgs[0]);
5205
5206 provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
5207 }
5208 }
5209
5210 try {
5211 if (isString(module)) {
5212 moduleFn = angularModule(module);
5213 instanceInjector.modules[module] = moduleFn;
5214 runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
5215 runInvokeQueue(moduleFn._invokeQueue);
5216 runInvokeQueue(moduleFn._configBlocks);
5217 } else if (isFunction(module)) {
5218 runBlocks.push(providerInjector.invoke(module));
5219 } else if (isArray(module)) {
5220 runBlocks.push(providerInjector.invoke(module));
5221 } else {
5222 assertArgFn(module, 'module');
5223 }
5224 } catch (e) {
5225 if (isArray(module)) {
5226 module = module[module.length - 1];
5227 }
5228 if (e.message && e.stack && e.stack.indexOf(e.message) === -1) {
5229 // Safari & FF's stack traces don't contain error.message content
5230 // unlike those of Chrome and IE
5231 // So if stack doesn't contain message, we create a new string that contains both.
5232 // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
5233 // eslint-disable-next-line no-ex-assign
5234 e = e.message + '\n' + e.stack;
5235 }
5236 throw $injectorMinErr('modulerr', 'Failed to instantiate module {0} due to:\n{1}',
5237 module, e.stack || e.message || e);
5238 }
5239 });
5240 return runBlocks;
5241 }
5242
5243 ////////////////////////////////////
5244 // internal Injector

Callers 1

createInjectorFunction · 0.85

Calls 10

assertArgFunction · 0.85
isUndefinedFunction · 0.85
isArrayFunction · 0.85
forEachFunction · 0.85
isStringFunction · 0.85
runInvokeQueueFunction · 0.85
isFunctionFunction · 0.85
assertArgFnFunction · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected