Comparing version 0.1.1 to 0.2.0
@@ -1,2 +0,3 @@ | ||
var async, freeflow; | ||
var async, freeflow, | ||
__slice = [].slice; | ||
@@ -19,11 +20,16 @@ async = require('async'); | ||
var match, ret; | ||
match = func.toString().match(/^function[^(]\(([^)]*)\)/); | ||
ret = match[1].split(',').map(function(x) { | ||
return x.replace(' ', ''); | ||
}); | ||
ret.pop(); | ||
ret = null; | ||
if (!Array.isArray(func)) { | ||
match = func.toString().match(/^function[^(]\(([^)]*)\)/); | ||
ret = match[1].split(',').map(function(x) { | ||
return x.replace(' ', ''); | ||
}); | ||
ret[ret.length - 1] = func; | ||
} else { | ||
ret = func; | ||
} | ||
return ret; | ||
}; | ||
execute = function(func_name, cb) { | ||
var dependencies, final_callback, func, name; | ||
var dependencies, final_callback, func, name, names, _i, _ref; | ||
if (cache[func_name]) { | ||
@@ -38,9 +44,8 @@ cb.apply(cb, cache[func_name]); | ||
waiting[func_name] = cb; | ||
func = methods[func_name]; | ||
_ref = inference(methods[func_name]), names = 2 <= _ref.length ? __slice.call(_ref, 0, _i = _ref.length - 1) : (_i = 0, []), func = _ref[_i++]; | ||
dependencies = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = inference(func); | ||
var _j, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
name = _ref[_i]; | ||
for (_j = 0, _len = names.length; _j < _len; _j++) { | ||
name = names[_j]; | ||
_results.push((function(name) { | ||
@@ -47,0 +52,0 @@ return function(cb) { |
{ | ||
"name": "freeflow", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Similar to async.auto, but offers partial calculation and different interface.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha", | ||
"prepublish": "grunt" | ||
}, | ||
@@ -9,0 +10,0 @@ "keywords": [ |
@@ -32,4 +32,15 @@ Freeflow | ||
If you don't like to use auto-inference feature, you can specify dependencies. | ||
var freeflow = require('freeflow'); | ||
freeflow({ | ||
funcA: function(callback) { ... }, | ||
funcB: function(callback) { ... }, | ||
funcC: [ 'funcA', 'funcB', function(AR, BR, callback) { ... } ] | ||
}, 'funcC', function(err, result) { | ||
... | ||
}); | ||
### TODO | ||
* Alternative way without dependency inference. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7606
71
46