diff options
Diffstat (limited to 'lib/internal')
-rw-r--r-- | lib/internal/filter.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/internal/filter.js b/lib/internal/filter.js index 454cc54..e191524 100644 --- a/lib/internal/filter.js +++ b/lib/internal/filter.js @@ -1,7 +1,8 @@ -import each from 'lodash/each'; import isArrayLike from 'lodash/isArrayLike'; import noop from 'lodash/noop'; + import once from './once'; +import iterator from './iterator'; export default function _filter(eachfn, coll, iteratee, callback) { callback = once(callback || noop); @@ -14,11 +15,13 @@ export default function _filter(eachfn, coll, iteratee, callback) { }, function (err) { if (err) return callback(err); var result = []; - each(coll, function(_, index) { - if (truthValues[index] === true) { - result.push(coll[index]); + var nextElem = iterator(coll); + var elem; + while ((elem = nextElem()) !== null) { + if (truthValues[elem.key] === true) { + result.push(elem.value); } - }); + } callback(null, result); }); } |