_basePickBy.js 791 B

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