(eachfn, arr, iterator, callback)
| 402 | }; |
| 403 | |
| 404 | function _filter(eachfn, arr, iterator, callback) { |
| 405 | var results = []; |
| 406 | eachfn(arr, function (x, index, callback) { |
| 407 | iterator(x, function (v) { |
| 408 | if (v) { |
| 409 | results.push({index: index, value: x}); |
| 410 | } |
| 411 | callback(); |
| 412 | }); |
| 413 | }, function () { |
| 414 | callback(_map(results.sort(function (a, b) { |
| 415 | return a.index - b.index; |
| 416 | }), function (x) { |
| 417 | return x.value; |
| 418 | })); |
| 419 | }); |
| 420 | } |
| 421 | |
| 422 | async.select = |
| 423 | async.filter = doParallel(_filter); |