diff --git a/lib/async.js b/lib/async.js index de50c7676..59ff57b97 100644 --- a/lib/async.js +++ b/lib/async.js @@ -416,24 +416,11 @@ async.filterSeries = doSeries(_filter); function _reject(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) { - if (!v) { - results.push(x); - } - callback(); + _filter(eachfn, arr, function(value, cb) { + iterator(value, function(v) { + cb(!v); }); - }, function () { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); + }, callback); } async.reject = doParallel(_reject); async.rejectSeries = doSeries(_reject);