blob: 1158d6d76f9669bd21a192e9650d9f2aaee7138a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import filter from 'lodash/_arrayFilter';
import noop from 'lodash/noop';
import once from './once';
export default function _filter(eachfn, arr, iteratee, callback) {
callback = once(callback || noop);
var truthy = [];
eachfn(arr, function (x, index, callback) {
iteratee(x, function (err, v) {
truthy[index] = !!v;
callback(err);
});
}, function (err) {
if (err) return callback(err);
callback(null, filter(arr, function (_, index) {
return truthy[index];
}));
});
}
|