Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

_basePickBy.js 791B

123456789101112131415161718192021222324252627282930
  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;