MCPcopy
hub / github.com/angular-ui/ui-grid / createInternalInjector

Function createInternalInjector

lib/test/angular/1.8.0/angular.js:5138–5236  ·  view source on GitHub ↗
(cache, factory)

Source from the content-addressed store, hash-verified

5136 ////////////////////////////////////
5137
5138 function createInternalInjector(cache, factory) {
5139
5140 function getService(serviceName, caller) {
5141 if (cache.hasOwnProperty(serviceName)) {
5142 if (cache[serviceName] === INSTANTIATING) {
5143 throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
5144 serviceName + ' <- ' + path.join(' <- '));
5145 }
5146 return cache[serviceName];
5147 } else {
5148 try {
5149 path.unshift(serviceName);
5150 cache[serviceName] = INSTANTIATING;
5151 cache[serviceName] = factory(serviceName, caller);
5152 return cache[serviceName];
5153 } catch (err) {
5154 if (cache[serviceName] === INSTANTIATING) {
5155 delete cache[serviceName];
5156 }
5157 throw err;
5158 } finally {
5159 path.shift();
5160 }
5161 }
5162 }
5163
5164
5165 function injectionArgs(fn, locals, serviceName) {
5166 var args = [],
5167 $inject = createInjector.$$annotate(fn, strictDi, serviceName);
5168
5169 for (var i = 0, length = $inject.length; i < length; i++) {
5170 var key = $inject[i];
5171 if (typeof key !== 'string') {
5172 throw $injectorMinErr('itkn',
5173 'Incorrect injection token! Expected service name as string, got {0}', key);
5174 }
5175 args.push(locals && locals.hasOwnProperty(key) ? locals[key] :
5176 getService(key, serviceName));
5177 }
5178 return args;
5179 }
5180
5181 function isClass(func) {
5182 // Support: IE 9-11 only
5183 // IE 9-11 do not support classes and IE9 leaks with the code below.
5184 if (msie || typeof func !== 'function') {
5185 return false;
5186 }
5187 var result = func.$$ngIsClass;
5188 if (!isBoolean(result)) {
5189 result = func.$$ngIsClass = /^class\b/.test(stringifyFn(func));
5190 }
5191 return result;
5192 }
5193
5194 function invoke(fn, self, locals, serviceName) {
5195 if (typeof locals === 'string') {

Callers 1

createInjectorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected