MCPcopy
hub / github.com/jquery/esprima / annotate

Function annotate

test/3rdparty/angular-1.2.5.js:2972–3000  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

2970var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
2971var $injectorMinErr = minErr('$injector');
2972function annotate(fn) {
2973 var $inject,
2974 fnText,
2975 argDecl,
2976 last;
2977
2978 if (typeof fn == 'function') {
2979 if (!($inject = fn.$inject)) {
2980 $inject = [];
2981 if (fn.length) {
2982 fnText = fn.toString().replace(STRIP_COMMENTS, '');
2983 argDecl = fnText.match(FN_ARGS);
2984 forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){
2985 arg.replace(FN_ARG, function(all, underscore, name){
2986 $inject.push(name);
2987 });
2988 });
2989 }
2990 fn.$inject = $inject;
2991 }
2992 } else if (isArray(fn)) {
2993 last = fn.length - 1;
2994 assertArgFn(fn[last], 'fn');
2995 $inject = fn.slice(0, last);
2996 } else {
2997 assertArgFn(fn, 'fn', true);
2998 }
2999 return $inject;
3000}
3001
3002///////////////////////////////////////
3003

Callers 1

invokeFunction · 0.85

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…