MCPcopy Index your code
hub / github.com/angular-ui/ui-router / createInternalInjector

Function createInternalInjector

test/angular/1.6/angular.js:5045–5145  ·  view source on GitHub ↗
(cache, factory)

Source from the content-addressed store, hash-verified

5043 ////////////////////////////////////
5044
5045 function createInternalInjector(cache, factory) {
5046
5047 function getService(serviceName, caller) {
5048 if (cache.hasOwnProperty(serviceName)) {
5049 if (cache[serviceName] === INSTANTIATING) {
5050 throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
5051 serviceName + ' <- ' + path.join(' <- '));
5052 }
5053 return cache[serviceName];
5054 } else {
5055 try {
5056 path.unshift(serviceName);
5057 cache[serviceName] = INSTANTIATING;
5058 cache[serviceName] = factory(serviceName, caller);
5059 return cache[serviceName];
5060 } catch (err) {
5061 if (cache[serviceName] === INSTANTIATING) {
5062 delete cache[serviceName];
5063 }
5064 throw err;
5065 } finally {
5066 path.shift();
5067 }
5068 }
5069 }
5070
5071
5072 function injectionArgs(fn, locals, serviceName) {
5073 var args = [],
5074 $inject = createInjector.$$annotate(fn, strictDi, serviceName);
5075
5076 for (var i = 0, length = $inject.length; i < length; i++) {
5077 var key = $inject[i];
5078 if (typeof key !== 'string') {
5079 throw $injectorMinErr('itkn',
5080 'Incorrect injection token! Expected service name as string, got {0}', key);
5081 }
5082 args.push(locals && locals.hasOwnProperty(key) ? locals[key] :
5083 getService(key, serviceName));
5084 }
5085 return args;
5086 }
5087
5088 function isClass(func) {
5089 // Support: IE 9-11 only
5090 // IE 9-11 do not support classes and IE9 leaks with the code below.
5091 if (msie || typeof func !== 'function') {
5092 return false;
5093 }
5094 var result = func.$$ngIsClass;
5095 if (!isBoolean(result)) {
5096 // Support: Edge 12-13 only
5097 // See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6156135/
5098 result = func.$$ngIsClass = /^(?:class\b|constructor\()/.test(stringifyFn(func));
5099 }
5100 return result;
5101 }
5102

Callers 1

createInjectorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected