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 isBuffer = require('./isBuffer'),
8 isTypedArray = require('./isTypedArray');
10 /** Used to compose bitmasks for value comparisons. */
11 var COMPARE_PARTIAL_FLAG = 1;
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 {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
33 * @param {Function} customizer The function to customize comparisons.
34 * @param {Function} equalFunc The function to determine equivalents of values.
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, bitmask, customizer, equalFunc, stack) {
39 var objIsArr = isArray(object),
40 othIsArr = isArray(other),
41 objTag = objIsArr ? arrayTag : getTag(object),
42 othTag = othIsArr ? arrayTag : getTag(other);
44 objTag = objTag == argsTag ? objectTag : objTag;
45 othTag = othTag == argsTag ? objectTag : othTag;
47 var objIsObj = objTag == objectTag,
48 othIsObj = othTag == objectTag,
49 isSameTag = objTag == othTag;
51 if (isSameTag && isBuffer(object)) {
52 if (!isBuffer(other)) {
58 if (isSameTag && !objIsObj) {
59 stack || (stack = new Stack);
60 return (objIsArr || isTypedArray(object))
61 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
62 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
64 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
65 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
66 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
68 if (objIsWrapped || othIsWrapped) {
69 var objUnwrapped = objIsWrapped ? object.value() : object,
70 othUnwrapped = othIsWrapped ? other.value() : other;
72 stack || (stack = new Stack);
73 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
79 stack || (stack = new Stack);
80 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
83 module.exports = baseIsEqualDeep;