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

Function annotate

test/angular/1.3/angular.js:3475–3510  ·  view source on GitHub ↗
(fn, strictDi, name)

Source from the content-addressed store, hash-verified

3473}
3474
3475function annotate(fn, strictDi, name) {
3476 var $inject,
3477 fnText,
3478 argDecl,
3479 last;
3480
3481 if (typeof fn === 'function') {
3482 if (!($inject = fn.$inject)) {
3483 $inject = [];
3484 if (fn.length) {
3485 if (strictDi) {
3486 if (!isString(name) || !name) {
3487 name = fn.name || anonFn(fn);
3488 }
3489 throw $injectorMinErr('strictdi',
3490 '{0} is not using explicit annotation and cannot be invoked in strict mode', name);
3491 }
3492 fnText = fn.toString().replace(STRIP_COMMENTS, '');
3493 argDecl = fnText.match(FN_ARGS);
3494 forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) {
3495 arg.replace(FN_ARG, function(all, underscore, name) {
3496 $inject.push(name);
3497 });
3498 });
3499 }
3500 fn.$inject = $inject;
3501 }
3502 } else if (isArray(fn)) {
3503 last = fn.length - 1;
3504 assertArgFn(fn[last], 'fn');
3505 $inject = fn.slice(0, last);
3506 } else {
3507 assertArgFn(fn, 'fn', true);
3508 }
3509 return $inject;
3510}
3511
3512///////////////////////////////////////
3513

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