isMatch.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. var baseIsMatch = require('./_baseIsMatch'),
  2. getMatchData = require('./_getMatchData');
  3. /**
  4. * Performs a partial deep comparison between `object` and `source` to
  5. * determine if `object` contains equivalent property values.
  6. *
  7. * **Note:** This method is equivalent to `_.matches` when `source` is
  8. * partially applied.
  9. *
  10. * Partial comparisons will match empty array and empty object `source`
  11. * values against any array or object value, respectively. See `_.isEqual`
  12. * for a list of supported value comparisons.
  13. *
  14. * @static
  15. * @memberOf _
  16. * @since 3.0.0
  17. * @category Lang
  18. * @param {Object} object The object to inspect.
  19. * @param {Object} source The object of property values to match.
  20. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  21. * @example
  22. *
  23. * var object = { 'a': 1, 'b': 2 };
  24. *
  25. * _.isMatch(object, { 'b': 2 });
  26. * // => true
  27. *
  28. * _.isMatch(object, { 'b': 1 });
  29. * // => false
  30. */
  31. function isMatch(object, source) {
  32. return object === source || baseIsMatch(object, source, getMatchData(source));
  33. }
  34. module.exports = isMatch;