Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

_baseMatchesProperty.js 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. var baseIsEqual = require('./_baseIsEqual'),
  2. get = require('./get'),
  3. hasIn = require('./hasIn'),
  4. isKey = require('./_isKey'),
  5. isStrictComparable = require('./_isStrictComparable'),
  6. matchesStrictComparable = require('./_matchesStrictComparable'),
  7. toKey = require('./_toKey');
  8. /** Used to compose bitmasks for value comparisons. */
  9. var COMPARE_PARTIAL_FLAG = 1,
  10. COMPARE_UNORDERED_FLAG = 2;
  11. /**
  12. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  13. *
  14. * @private
  15. * @param {string} path The path of the property to get.
  16. * @param {*} srcValue The value to match.
  17. * @returns {Function} Returns the new spec function.
  18. */
  19. function baseMatchesProperty(path, srcValue) {
  20. if (isKey(path) && isStrictComparable(srcValue)) {
  21. return matchesStrictComparable(toKey(path), srcValue);
  22. }
  23. return function(object) {
  24. var objValue = get(object, path);
  25. return (objValue === undefined && objValue === srcValue)
  26. ? hasIn(object, path)
  27. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  28. };
  29. }
  30. module.exports = baseMatchesProperty;