MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / annotate

Function annotate

code/songhop/www/lib/angular/angular.js:3426–3461  ·  view source on GitHub ↗
(fn, strictDi, name)

Source from the content-addressed store, hash-verified

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

Callers 1

invokeFunction · 0.70

Calls 4

isStringFunction · 0.70
anonFnFunction · 0.70
forEachFunction · 0.70
assertArgFnFunction · 0.70

Tested by

no test coverage detected