MCPcopy
hub / github.com/angular-ui/ui-router / annotate

Function annotate

test/angular/1.4/angular.js:3811–3846  ·  view source on GitHub ↗
(fn, strictDi, name)

Source from the content-addressed store, hash-verified

3809}
3810
3811function annotate(fn, strictDi, name) {
3812 var $inject,
3813 fnText,
3814 argDecl,
3815 last;
3816
3817 if (typeof fn === 'function') {
3818 if (!($inject = fn.$inject)) {
3819 $inject = [];
3820 if (fn.length) {
3821 if (strictDi) {
3822 if (!isString(name) || !name) {
3823 name = fn.name || anonFn(fn);
3824 }
3825 throw $injectorMinErr('strictdi',
3826 '{0} is not using explicit annotation and cannot be invoked in strict mode', name);
3827 }
3828 fnText = fn.toString().replace(STRIP_COMMENTS, '');
3829 argDecl = fnText.match(FN_ARGS);
3830 forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) {
3831 arg.replace(FN_ARG, function(all, underscore, name) {
3832 $inject.push(name);
3833 });
3834 });
3835 }
3836 fn.$inject = $inject;
3837 }
3838 } else if (isArray(fn)) {
3839 last = fn.length - 1;
3840 assertArgFn(fn[last], 'fn');
3841 $inject = fn.slice(0, last);
3842 } else {
3843 assertArgFn(fn, 'fn', true);
3844 }
3845 return $inject;
3846}
3847
3848///////////////////////////////////////
3849

Callers

nothing calls this directly

Calls 6

isArrayFunction · 0.85
matchMethod · 0.80
isStringFunction · 0.70
anonFnFunction · 0.70
forEachFunction · 0.70
assertArgFnFunction · 0.70

Tested by

no test coverage detected