isMatch.js 973 B

1234567891011121314151617181920212223242526272829303132
  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. This method is
  6. * equivalent to a `_.matches` function when `source` is partially applied.
  7. *
  8. * **Note:** This method supports comparing the same values as `_.isEqual`.
  9. *
  10. * @static
  11. * @memberOf _
  12. * @since 3.0.0
  13. * @category Lang
  14. * @param {Object} object The object to inspect.
  15. * @param {Object} source The object of property values to match.
  16. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  17. * @example
  18. *
  19. * var object = { 'user': 'fred', 'age': 40 };
  20. *
  21. * _.isMatch(object, { 'age': 40 });
  22. * // => true
  23. *
  24. * _.isMatch(object, { 'age': 36 });
  25. * // => false
  26. */
  27. function isMatch(object, source) {
  28. return object === source || baseIsMatch(object, source, getMatchData(source));
  29. }
  30. module.exports = isMatch;