1 var Stack = require('./_Stack'),
2 equalArrays = require('./_equalArrays'),
3 equalByTag = require('./_equalByTag'),
4 equalObjects = require('./_equalObjects'),
5 getTag = require('./_getTag'),
6 isArray = require('./isArray'),
7 isHostObject = require('./_isHostObject'),
8 isTypedArray = require('./isTypedArray');
10 /** Used to compose bitmasks for comparison styles. */
11 var PARTIAL_COMPARE_FLAG = 2;
13 /** `Object#toString` result references. */
14 var argsTag = '[object Arguments]',
15 arrayTag = '[object Array]',
16 objectTag = '[object Object]';
18 /** Used for built-in method references. */
19 var objectProto = Object.prototype;
21 /** Used to check objects for own properties. */
22 var hasOwnProperty = objectProto.hasOwnProperty;
25 * A specialized version of `baseIsEqual` for arrays and objects which performs
26 * deep comparisons and tracks traversed objects enabling objects with circular
27 * references to be compared.
30 * @param {Object} object The object to compare.
31 * @param {Object} other The other object to compare.
32 * @param {Function} equalFunc The function to determine equivalents of values.
33 * @param {Function} [customizer] The function to customize comparisons.
34 * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
35 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
36 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
38 function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
39 var objIsArr = isArray(object),
40 othIsArr = isArray(other),
45 objTag = getTag(object);
46 if (objTag == argsTag) {
48 } else if (objTag != objectTag) {
49 objIsArr = isTypedArray(object);
53 othTag = getTag(other);
54 if (othTag == argsTag) {
56 } else if (othTag != objectTag) {
57 othIsArr = isTypedArray(other);
60 var objIsObj = objTag == objectTag && !isHostObject(object),
61 othIsObj = othTag == objectTag && !isHostObject(other),
62 isSameTag = objTag == othTag;
64 if (isSameTag && !(objIsArr || objIsObj)) {
65 return equalByTag(object, other, objTag, equalFunc, customizer, bitmask);
67 var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
69 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
70 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
72 if (objIsWrapped || othIsWrapped) {
73 return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
79 stack || (stack = new Stack);
80 return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack);
83 module.exports = baseIsEqualDeep;