You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 rivejä
791 B

4 vuotta sitten
  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;