1 var keys = require('../object/keys');
3 /** Used for native method references. */
4 var objectProto = Object.prototype;
6 /** Used to check objects for own properties. */
7 var hasOwnProperty = objectProto.hasOwnProperty;
10 * A specialized version of `baseIsEqualDeep` for objects with support for
11 * partial deep comparisons.
14 * @param {Object} object The object to compare.
15 * @param {Object} other The other object to compare.
16 * @param {Function} equalFunc The function to determine equivalents of values.
17 * @param {Function} [customizer] The function to customize comparing values.
18 * @param {boolean} [isLoose] Specify performing partial comparisons.
19 * @param {Array} [stackA] Tracks traversed `value` objects.
20 * @param {Array} [stackB] Tracks traversed `other` objects.
21 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
23 function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
24 var objProps = keys(object),
25 objLength = objProps.length,
26 othProps = keys(other),
27 othLength = othProps.length;
29 if (objLength != othLength && !isLoose) {
32 var index = objLength;
34 var key = objProps[index];
35 if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
39 var skipCtor = isLoose;
40 while (++index < objLength) {
41 key = objProps[index];
42 var objValue = object[key],
43 othValue = other[key],
44 result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
46 // Recursively compare objects (susceptible to call stack limits).
47 if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
50 skipCtor || (skipCtor = key == 'constructor');
53 var objCtor = object.constructor,
54 othCtor = other.constructor;
56 // Non `Object` object instances with different constructors are not equal.
57 if (objCtor != othCtor &&
58 ('constructor' in object && 'constructor' in other) &&
59 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
60 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
67 module.exports = equalObjects;