MCPcopy Create free account
hub / github.com/apache/cloudstack / annotate

Function annotate

tools/ngui/static/js/lib/angular.js:2367–2393  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

2365var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
2366var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
2367function annotate(fn) {
2368 var $inject,
2369 fnText,
2370 argDecl,
2371 last;
2372
2373 if (typeof fn == 'function') {
2374 if (!($inject = fn.$inject)) {
2375 $inject = [];
2376 fnText = fn.toString().replace(STRIP_COMMENTS, '');
2377 argDecl = fnText.match(FN_ARGS);
2378 forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){
2379 arg.replace(FN_ARG, function(all, underscore, name){
2380 $inject.push(name);
2381 });
2382 });
2383 fn.$inject = $inject;
2384 }
2385 } else if (isArray(fn)) {
2386 last = fn.length - 1;
2387 assertArgFn(fn[last], 'fn');
2388 $inject = fn.slice(0, last);
2389 } else {
2390 assertArgFn(fn, 'fn', true);
2391 }
2392 return $inject;
2393}
2394
2395///////////////////////////////////////
2396

Callers 1

invokeFunction · 0.85

Calls 7

forEachFunction · 0.85
isArrayFunction · 0.85
assertArgFnFunction · 0.85
replaceMethod · 0.80
sliceMethod · 0.80
toStringMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected