MCPcopy Create free account
hub / github.com/bclinkinbeard/angular / loadModules

Function loadModules

test/fixtures/foo.js:3870–3911  ·  view source on GitHub ↗
(modulesToLoad)

Source from the content-addressed store, hash-verified

3868 // Module Loading
3869 ////////////////////////////////////
3870 function loadModules(modulesToLoad){
3871 var runBlocks = [], moduleFn, invokeQueue, i, ii;
3872 forEach(modulesToLoad, function(module) {
3873 if (loadedModules.get(module)) return;
3874 loadedModules.put(module, true);
3875
3876 try {
3877 if (isString(module)) {
3878 moduleFn = angularModule(module);
3879 runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
3880
3881 for(invokeQueue = moduleFn._invokeQueue, i = 0, ii = invokeQueue.length; i < ii; i++) {
3882 var invokeArgs = invokeQueue[i],
3883 provider = providerInjector.get(invokeArgs[0]);
3884
3885 provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
3886 }
3887 } else if (isFunction(module)) {
3888 runBlocks.push(providerInjector.invoke(module));
3889 } else if (isArray(module)) {
3890 runBlocks.push(providerInjector.invoke(module));
3891 } else {
3892 assertArgFn(module, 'module');
3893 }
3894 } catch (e) {
3895 if (isArray(module)) {
3896 module = module[module.length - 1];
3897 }
3898 if (e.message && e.stack && e.stack.indexOf(e.message) == -1) {
3899 // Safari & FF's stack traces don't contain error.message content
3900 // unlike those of Chrome and IE
3901 // So if stack doesn't contain message, we create a new string that contains both.
3902 // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
3903 /* jshint -W022 */
3904 e = e.message + '\n' + e.stack;
3905 }
3906 throw $injectorMinErr('modulerr', "Failed to instantiate module {0} due to:\n{1}",
3907 module, e.stack || e.message || e);
3908 }
3909 });
3910 return runBlocks;
3911 }
3912
3913 ////////////////////////////////////
3914 // internal Injector

Callers 1

createInjectorFunction · 0.85

Calls 4

forEachFunction · 0.85
isStringFunction · 0.85
isFunctionFunction · 0.85
assertArgFnFunction · 0.85

Tested by

no test coverage detected