func-deps
Determines a function's dependencies based on its signature or annotations
Last updated 6 years ago by itsananderson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install func-deps 
SYNC missed versions from official npm registry.

func-deps NPM version Builds

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 = require('func-deps');

funcDeps(function(){});
// => returns { deps: [], func: function(){} }

funcDeps(function(a, b){});
// => 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 = require('func-deps');

funcDeps(['a', 'b', function(c, d){}]);
// => returns { deps: ['a', 'b'], func: function(c, d){} }

funcDeps(['a', 'b', function(){}]);
// => 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 = require('func-deps');

function test() {};
test.$inject = ['a', 'b'];
funcDeps(test);
// => returns { deps: ['a', 'b'], func: function test(){} }

Current Tags

  • 0.1.1                                ...           latest (6 years ago)

2 Versions

  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (1)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |