MCPcopy Create free account
hub / github.com/aosabook/500lines / annotate

Function annotate

spreadsheet/code/lib/angular.js:3419–3454  ·  view source on GitHub ↗
(fn, strictDi, name)

Source from the content-addressed store, hash-verified

3417}
3418
3419function annotate(fn, strictDi, name) {
3420 var $inject,
3421 fnText,
3422 argDecl,
3423 last;
3424
3425 if (typeof fn === 'function') {
3426 if (!($inject = fn.$inject)) {
3427 $inject = [];
3428 if (fn.length) {
3429 if (strictDi) {
3430 if (!isString(name) || !name) {
3431 name = fn.name || anonFn(fn);
3432 }
3433 throw $injectorMinErr('strictdi',
3434 '{0} is not using explicit annotation and cannot be invoked in strict mode', name);
3435 }
3436 fnText = fn.toString().replace(STRIP_COMMENTS, '');
3437 argDecl = fnText.match(FN_ARGS);
3438 forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) {
3439 arg.replace(FN_ARG, function(all, underscore, name) {
3440 $inject.push(name);
3441 });
3442 });
3443 }
3444 fn.$inject = $inject;
3445 }
3446 } else if (isArray(fn)) {
3447 last = fn.length - 1;
3448 assertArgFn(fn[last], 'fn');
3449 $inject = fn.slice(0, last);
3450 } else {
3451 assertArgFn(fn, 'fn', true);
3452 }
3453 return $inject;
3454}
3455
3456///////////////////////////////////////
3457

Callers 1

invokeFunction · 0.85

Calls 5

isStringFunction · 0.85
anonFnFunction · 0.85
forEachFunction · 0.85
assertArgFnFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected