_baseMatches.js 710 B

1234567891011121314151617181920212223
  1. var baseIsMatch = require('./_baseIsMatch'),
  2. getMatchData = require('./_getMatchData'),
  3. matchesStrictComparable = require('./_matchesStrictComparable');
  4. /**
  5. * The base implementation of `_.matches` which doesn't clone `source`.
  6. *
  7. * @private
  8. * @param {Object} source The object of property values to match.
  9. * @returns {Function} Returns the new spec function.
  10. */
  11. function baseMatches(source) {
  12. var matchData = getMatchData(source);
  13. if (matchData.length == 1 && matchData[0][2]) {
  14. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  15. }
  16. return function(object) {
  17. return object === source || baseIsMatch(object, source, matchData);
  18. };
  19. }
  20. module.exports = baseMatches;