import arrayMap from 'lodash/_arrayMap';
import property from 'lodash/_baseProperty';
import noop from 'lodash/noop';
import once from './once';

export default function _filter(eachfn, arr, iteratee, callback) {
    callback = once(callback || noop);
    var results = [];
    eachfn(arr, function (x, index, callback) {
        iteratee(x, function (err, v) {
            if (err) {
                callback(err);
            } else {
                if (v) {
                    results.push({index: index, value: x});
                }
                callback();
            }
        });
    }, function (err) {
        if (err) {
            callback(err);
        } else {
            callback(null, arrayMap(results.sort(function (a, b) {
                return a.index - b.index;
            }), property('value')));
        }
    });
}

@@ -30,24 +30,70 @@
 _arrayMap';%0A
+import isArrayLike from 'lodash/isArrayLike';%0A
 import prope
@@ -161,141 +161,577 @@
 p';%0A
-import once from './once';%0A%0Aexport default function _filter(eachfn, arr, iteratee, callback) %7B%0A    callback = once(callback %7C%7C noop);
+%0Afunction filterArray(eachfn, arr, iteratee, callback) %7B%0A    var truthValues = new Array(arr.length);%0A    eachfn(arr, function (x, index, callback) %7B%0A        iteratee(x, function (err, v) %7B%0A            truthValues%5Bindex%5D = !!v;%0A            callback(err);%0A        %7D);%0A    %7D, function (err) %7B%0A        if (err) return callback(err);%0A        var results = %5B%5D;%0A        for (var i = 0; i %3C arr.length; i++) %7B%0A            if (truthValues%5Bi%5D) results.push(arr%5Bi%5D);%0A        %7D%0A        callback(null, results);%0A    %7D);%0A%7D%0A%0Afunction filterGeneric(eachfn, coll, iteratee, callback) %7B
 %0A   
@@ -752,35 +752,36 @@
  %5B%5D;%0A    eachfn(
-arr
+coll
 , function (x, i
@@ -1315,16 +1315,207 @@
     %7D%0A    %7D);%0A%7D%0A
+%0Aexport default function _filter(eachfn, coll, iteratee, callback) %7B%0A    var filter = isArrayLike(coll) ? filterArray : filterGeneric;%0A    filter(eachfn, coll, iteratee, callback %7C%7C noop);%0A%7D%0A

Implement array specific filter function