MCPcopy
hub / github.com/lodash/lodash / baseIsEqualDeep

Function baseIsEqualDeep

lodash.js:3338–3381  ·  view source on GitHub ↗

* A specialized version of `baseIsEqual` for arrays and objects which performs * deep comparisons and tracks traversed objects enabling objects with circular * references to be compared. * * @private * @param {Object} object The object to compare. * @param {Object} othe

(object, other, bitmask, customizer, equalFunc, stack)

Source from the content-addressed store, hash-verified

3336 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3337 */
3338 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3339 var objIsArr = isArray(object),
3340 othIsArr = isArray(other),
3341 objTag = objIsArr ? arrayTag : getTag(object),
3342 othTag = othIsArr ? arrayTag : getTag(other);
3343
3344 objTag = objTag == argsTag ? objectTag : objTag;
3345 othTag = othTag == argsTag ? objectTag : othTag;
3346
3347 var objIsObj = objTag == objectTag,
3348 othIsObj = othTag == objectTag,
3349 isSameTag = objTag == othTag;
3350
3351 if (isSameTag && isBuffer(object)) {
3352 if (!isBuffer(other)) {
3353 return false;
3354 }
3355 objIsArr = true;
3356 objIsObj = false;
3357 }
3358 if (isSameTag && !objIsObj) {
3359 stack || (stack = new Stack);
3360 return (objIsArr || isTypedArray(object))
3361 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
3362 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3363 }
3364 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
3365 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3366 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3367
3368 if (objIsWrapped || othIsWrapped) {
3369 var objUnwrapped = objIsWrapped ? object.value() : object,
3370 othUnwrapped = othIsWrapped ? other.value() : other;
3371
3372 stack || (stack = new Stack);
3373 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3374 }
3375 }
3376 if (!isSameTag) {
3377 return false;
3378 }
3379 stack || (stack = new Stack);
3380 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3381 }
3382
3383 /**
3384 * The base implementation of `_.isMap` without Node.js optimizations.

Callers 1

baseIsEqualFunction · 0.85

Calls 3

equalArraysFunction · 0.85
equalByTagFunction · 0.85
equalObjectsFunction · 0.85

Tested by

no test coverage detected