UNPKG

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