diff options
author | Graeme Yeates <yeatesgraeme@gmail.com> | 2015-07-03 01:52:44 -0400 |
---|---|---|
committer | Graeme Yeates <yeatesgraeme@gmail.com> | 2015-07-03 01:52:44 -0400 |
commit | 7fbad2ab8aadad878693e2a462ac22cc82c505af (patch) | |
tree | f62122833009fde996a95a832c68fc0b20250fd5 /lib | |
parent | 6364921f71c4f6eac84e54d8287eea9d6006e7e6 (diff) | |
download | async-7fbad2ab8aadad878693e2a462ac22cc82c505af.tar.gz |
Avoid unnecessary loop in filter
Diffstat (limited to 'lib')
-rw-r--r-- | lib/async.js | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/async.js b/lib/async.js index 67404c7..7aa32b9 100644 --- a/lib/async.js +++ b/lib/async.js @@ -405,13 +405,10 @@ function _filter(eachfn, arr, iterator, callback) { var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); eachfn(arr, function (x, index, callback) { - iterator(x.value, function (v) { + iterator(x, function (v) { if (v) { - results.push(x); + results.push({index: index, value: x}); } callback(); }); |