MCPcopy Create free account
hub / github.com/bclinkinbeard/angular / annotate

Function annotate

test/fixtures/foo.js:3264–3292  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

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

Callers 1

invokeFunction · 0.85

Calls 2

forEachFunction · 0.85
assertArgFnFunction · 0.85

Tested by

no test coverage detected