_basePickBy.js 660 B

12345678910111213141516171819202122232425262728
  1. var getAllKeysIn = require('./_getAllKeysIn');
  2. /**
  3. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  4. *
  5. * @private
  6. * @param {Object} object The source object.
  7. * @param {Function} predicate The function invoked per property.
  8. * @returns {Object} Returns the new object.
  9. */
  10. function basePickBy(object, predicate) {
  11. var index = -1,
  12. props = getAllKeysIn(object),
  13. length = props.length,
  14. result = {};
  15. while (++index < length) {
  16. var key = props[index],
  17. value = object[key];
  18. if (predicate(value, key)) {
  19. result[key] = value;
  20. }
  21. }
  22. return result;
  23. }
  24. module.exports = basePickBy;