You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
710 B

4 years ago
  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;