baseIsEqual.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import baseIsEqualDeep from './baseIsEqualDeep';
  2. import isObject from '../isObject';
  3. import isObjectLike from '../isObjectLike';
  4. /**
  5. * The base implementation of `_.isEqual` which supports partial comparisons
  6. * and tracks traversed objects.
  7. *
  8. * @private
  9. * @param {*} value The value to compare.
  10. * @param {*} other The other value to compare.
  11. * @param {Function} [customizer] The function to customize comparisons.
  12. * @param {boolean} [bitmask] The bitmask of comparison flags.
  13. * The bitmask may be composed of the following flags:
  14. * 1 - Unordered comparison
  15. * 2 - Partial comparison
  16. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  17. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  18. */
  19. function baseIsEqual(value, other, customizer, bitmask, stack) {
  20. if (value === other) {
  21. return true;
  22. }
  23. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  24. return value !== value && other !== other;
  25. }
  26. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  27. }
  28. export default baseIsEqual;