summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Shvets <github@sashok.mk.ua>2013-07-22 09:27:14 +0300
committerAlex Shvets <github@sashok.mk.ua>2013-07-22 09:27:14 +0300
commitc508e5e96a82e7bbe92fbf4cc070331dae2fb072 (patch)
tree527bbedfffbc92224f0547a581835950f85c29cb
parentd8601a17ab0bc6a1572227998b6e9182637f37b6 (diff)
downloadasync-c508e5e96a82e7bbe92fbf4cc070331dae2fb072.tar.gz
make done callback function (instead of function-expression): dont create it new on each iteration
-rwxr-xr-xlib/async.js25
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;