MCPcopy Index your code
hub / github.com/angular-ui/ui-router / annotate

Function annotate

test/angular/1.2/angular.js:3266–3294  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

3264var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
3265var $injectorMinErr = minErr('$injector');
3266function annotate(fn) {
3267 var $inject,
3268 fnText,
3269 argDecl,
3270 last;
3271
3272 if (typeof fn === 'function') {
3273 if (!($inject = fn.$inject)) {
3274 $inject = [];
3275 if (fn.length) {
3276 fnText = fn.toString().replace(STRIP_COMMENTS, '');
3277 argDecl = fnText.match(FN_ARGS);
3278 forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){
3279 arg.replace(FN_ARG, function(all, underscore, name){
3280 $inject.push(name);
3281 });
3282 });
3283 }
3284 fn.$inject = $inject;
3285 }
3286 } else if (isArray(fn)) {
3287 last = fn.length - 1;
3288 assertArgFn(fn[last], 'fn');
3289 $inject = fn.slice(0, last);
3290 } else {
3291 assertArgFn(fn, 'fn', true);
3292 }
3293 return $inject;
3294}
3295
3296///////////////////////////////////////
3297

Callers 1

invokeFunction · 0.70

Calls 4

isArrayFunction · 0.85
matchMethod · 0.80
forEachFunction · 0.70
assertArgFnFunction · 0.70

Tested by

no test coverage detected