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

Function createInternalInjector

test/angular/1.5/angular.js:4703–4799  ·  view source on GitHub ↗
(cache, factory)

Source from the content-addressed store, hash-verified

4701 ////////////////////////////////////
4702
4703 function createInternalInjector(cache, factory) {
4704
4705 function getService(serviceName, caller) {
4706 if (cache.hasOwnProperty(serviceName)) {
4707 if (cache[serviceName] === INSTANTIATING) {
4708 throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
4709 serviceName + ' <- ' + path.join(' <- '));
4710 }
4711 return cache[serviceName];
4712 } else {
4713 try {
4714 path.unshift(serviceName);
4715 cache[serviceName] = INSTANTIATING;
4716 cache[serviceName] = factory(serviceName, caller);
4717 return cache[serviceName];
4718 } catch (err) {
4719 if (cache[serviceName] === INSTANTIATING) {
4720 delete cache[serviceName];
4721 }
4722 throw err;
4723 } finally {
4724 path.shift();
4725 }
4726 }
4727 }
4728
4729
4730 function injectionArgs(fn, locals, serviceName) {
4731 var args = [],
4732 $inject = createInjector.$$annotate(fn, strictDi, serviceName);
4733
4734 for (var i = 0, length = $inject.length; i < length; i++) {
4735 var key = $inject[i];
4736 if (typeof key !== 'string') {
4737 throw $injectorMinErr('itkn',
4738 'Incorrect injection token! Expected service name as string, got {0}', key);
4739 }
4740 args.push(locals && locals.hasOwnProperty(key) ? locals[key] :
4741 getService(key, serviceName));
4742 }
4743 return args;
4744 }
4745
4746 function isClass(func) {
4747 // IE 9-11 do not support classes and IE9 leaks with the code below.
4748 if (msie <= 11) {
4749 return false;
4750 }
4751 // Support: Edge 12-13 only
4752 // See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6156135/
4753 return typeof func === 'function'
4754 && /^(?:class\b|constructor\()/.test(stringifyFn(func));
4755 }
4756
4757 function invoke(fn, self, locals, serviceName) {
4758 if (typeof locals === 'string') {
4759 serviceName = locals;
4760 locals = null;

Callers 1

createInjectorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected