MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / annotate

Function annotate

web/static/bower_components/angular/angular.js:3733–3768  ·  view source on GitHub ↗
(fn, strictDi, name)

Source from the content-addressed store, hash-verified

3731}
3732
3733function annotate(fn, strictDi, name) {
3734 var $inject,
3735 fnText,
3736 argDecl,
3737 last;
3738
3739 if (typeof fn === 'function') {
3740 if (!($inject = fn.$inject)) {
3741 $inject = [];
3742 if (fn.length) {
3743 if (strictDi) {
3744 if (!isString(name) || !name) {
3745 name = fn.name || anonFn(fn);
3746 }
3747 throw $injectorMinErr('strictdi',
3748 '{0} is not using explicit annotation and cannot be invoked in strict mode', name);
3749 }
3750 fnText = fn.toString().replace(STRIP_COMMENTS, '');
3751 argDecl = fnText.match(FN_ARGS);
3752 forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) {
3753 arg.replace(FN_ARG, function(all, underscore, name) {
3754 $inject.push(name);
3755 });
3756 });
3757 }
3758 fn.$inject = $inject;
3759 }
3760 } else if (isArray(fn)) {
3761 last = fn.length - 1;
3762 assertArgFn(fn[last], 'fn');
3763 $inject = fn.slice(0, last);
3764 } else {
3765 assertArgFn(fn, 'fn', true);
3766 }
3767 return $inject;
3768}
3769
3770///////////////////////////////////////
3771

Callers

nothing calls this directly

Calls 4

isStringFunction · 0.85
anonFnFunction · 0.85
forEachFunction · 0.85
assertArgFnFunction · 0.85

Tested by

no test coverage detected