Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

41 rinda
1.3 KiB

pirms 4 gadiem
  1. var baseIsMatch = require('./_baseIsMatch'),
  2. getMatchData = require('./_getMatchData');
  3. /**
  4. * This method is like `_.isMatch` except that it accepts `customizer` which
  5. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  6. * are handled by the method instead. The `customizer` is invoked with five
  7. * arguments: (objValue, srcValue, index|key, object, source).
  8. *
  9. * @static
  10. * @memberOf _
  11. * @since 4.0.0
  12. * @category Lang
  13. * @param {Object} object The object to inspect.
  14. * @param {Object} source The object of property values to match.
  15. * @param {Function} [customizer] The function to customize comparisons.
  16. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  17. * @example
  18. *
  19. * function isGreeting(value) {
  20. * return /^h(?:i|ello)$/.test(value);
  21. * }
  22. *
  23. * function customizer(objValue, srcValue) {
  24. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  25. * return true;
  26. * }
  27. * }
  28. *
  29. * var object = { 'greeting': 'hello' };
  30. * var source = { 'greeting': 'hi' };
  31. *
  32. * _.isMatchWith(object, source, customizer);
  33. * // => true
  34. */
  35. function isMatchWith(object, source, customizer) {
  36. customizer = typeof customizer == 'function' ? customizer : undefined;
  37. return baseIsMatch(object, source, getMatchData(source), customizer);
  38. }
  39. module.exports = isMatchWith;