MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / annotate

Function annotate

lib/test/angular/1.4.3/angular.js:3706–3741  ·  view source on GitHub ↗
(fn, strictDi, name)

Source from the content-addressed store, hash-verified

3704}
3705
3706function annotate(fn, strictDi, name) {
3707 var $inject,
3708 fnText,
3709 argDecl,
3710 last;
3711
3712 if (typeof fn === 'function') {
3713 if (!($inject = fn.$inject)) {
3714 $inject = [];
3715 if (fn.length) {
3716 if (strictDi) {
3717 if (!isString(name) || !name) {
3718 name = fn.name || anonFn(fn);
3719 }
3720 throw $injectorMinErr('strictdi',
3721 '{0} is not using explicit annotation and cannot be invoked in strict mode', name);
3722 }
3723 fnText = fn.toString().replace(STRIP_COMMENTS, '');
3724 argDecl = fnText.match(FN_ARGS);
3725 forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) {
3726 arg.replace(FN_ARG, function(all, underscore, name) {
3727 $inject.push(name);
3728 });
3729 });
3730 }
3731 fn.$inject = $inject;
3732 }
3733 } else if (isArray(fn)) {
3734 last = fn.length - 1;
3735 assertArgFn(fn[last], 'fn');
3736 $inject = fn.slice(0, last);
3737 } else {
3738 assertArgFn(fn, 'fn', true);
3739 }
3740 return $inject;
3741}
3742
3743///////////////////////////////////////
3744

Callers

nothing calls this directly

Calls 5

isStringFunction · 0.70
anonFnFunction · 0.70
forEachFunction · 0.70
assertArgFnFunction · 0.70
isArrayFunction · 0.50

Tested by

no test coverage detected