func-deps
Determines a function's dependencies based on its signature or annotations
Similar to the AngularJS $injector
Installation
npm install func-deps
Usage
Call func-deps with a function, and it returns an object with two properties: deps
and func
.
var funcDeps = ; ;// => returns { deps: [], func: function(){} } ;// => returns { deps: ['a', 'b'], func: function(a, b){} }
You can also pass func-deps an array, where the first args are string dependencies, and the last arg is the function.
var funcDeps = ; ;// => returns { deps: ['a', 'b'], func: function(c, d){} } ;// => returns { deps: ['a', 'b'], func: function(){} }
If no array annotation is provided, and the function has a $inject
property that is an array, the $inject
property is assumed to be the dependency list.
var funcDeps = ; {};test$inject = 'a' 'b';;// => returns { deps: ['a', 'b'], func: function test(){} }