diff options
author | Alex Shvets <github@sashok.mk.ua> | 2013-07-22 09:27:14 +0300 |
---|---|---|
committer | Alex Shvets <github@sashok.mk.ua> | 2013-07-22 09:27:14 +0300 |
commit | c508e5e96a82e7bbe92fbf4cc070331dae2fb072 (patch) | |
tree | 527bbedfffbc92224f0547a581835950f85c29cb | |
parent | d8601a17ab0bc6a1572227998b6e9182637f37b6 (diff) | |
download | async-c508e5e96a82e7bbe92fbf4cc070331dae2fb072.tar.gz |
make done callback function (instead of function-expression): dont create it new on each iteration
-rwxr-xr-x | lib/async.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/async.js b/lib/async.js index cb6320d..f737623 100755 --- a/lib/async.js +++ b/lib/async.js @@ -105,19 +105,20 @@ } var completed = 0; _each(arr, function (x) { - iterator(x, only_once(function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - if (completed >= arr.length) { - callback(null); - } - } - })); + iterator(x, only_once(done) ); }); + function done(err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + if (completed >= arr.length) { + callback(null); + } + } + } }; async.forEach = async.each; |