2c407677685fce97b4561e669dfc4d169c4f8e9d6dcf34fe83bf364299464f89d91c179324654f97ec658acd70cd19a4696666225cc3d5501ac37d3bce1bfe 588 B

123456789101112131415161718192021
  1. import baseEach from './_baseEach.js';
  2. /**
  3. * The base implementation of `_.filter` without support for iteratee shorthands.
  4. *
  5. * @private
  6. * @param {Array|Object} collection The collection to iterate over.
  7. * @param {Function} predicate The function invoked per iteration.
  8. * @returns {Array} Returns the new filtered array.
  9. */
  10. function baseFilter(collection, predicate) {
  11. var result = [];
  12. baseEach(collection, function(value, index, collection) {
  13. if (predicate(value, index, collection)) {
  14. result.push(value);
  15. }
  16. });
  17. return result;
  18. }
  19. export default baseFilter;