react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / internal / baseIsEqualDeep.js
80742 viewsvar equalArrays = require('./equalArrays'),1equalByTag = require('./equalByTag'),2equalObjects = require('./equalObjects'),3isArray = require('../lang/isArray'),4isTypedArray = require('../lang/isTypedArray');56/** `Object#toString` result references. */7var argsTag = '[object Arguments]',8arrayTag = '[object Array]',9objectTag = '[object Object]';1011/** Used for native method references. */12var objectProto = Object.prototype;1314/** Used to check objects for own properties. */15var hasOwnProperty = objectProto.hasOwnProperty;1617/**18* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)19* of values.20*/21var objToString = objectProto.toString;2223/**24* A specialized version of `baseIsEqual` for arrays and objects which performs25* deep comparisons and tracks traversed objects enabling objects with circular26* references to be compared.27*28* @private29* @param {Object} object The object to compare.30* @param {Object} other The other object to compare.31* @param {Function} equalFunc The function to determine equivalents of values.32* @param {Function} [customizer] The function to customize comparing objects.33* @param {boolean} [isLoose] Specify performing partial comparisons.34* @param {Array} [stackA=[]] Tracks traversed `value` objects.35* @param {Array} [stackB=[]] Tracks traversed `other` objects.36* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.37*/38function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {39var objIsArr = isArray(object),40othIsArr = isArray(other),41objTag = arrayTag,42othTag = arrayTag;4344if (!objIsArr) {45objTag = objToString.call(object);46if (objTag == argsTag) {47objTag = objectTag;48} else if (objTag != objectTag) {49objIsArr = isTypedArray(object);50}51}52if (!othIsArr) {53othTag = objToString.call(other);54if (othTag == argsTag) {55othTag = objectTag;56} else if (othTag != objectTag) {57othIsArr = isTypedArray(other);58}59}60var objIsObj = objTag == objectTag,61othIsObj = othTag == objectTag,62isSameTag = objTag == othTag;6364if (isSameTag && !(objIsArr || objIsObj)) {65return equalByTag(object, other, objTag);66}67if (!isLoose) {68var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),69othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');7071if (objIsWrapped || othIsWrapped) {72return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);73}74}75if (!isSameTag) {76return false;77}78// Assume cyclic values are equal.79// For more information on detecting circular references see https://es5.github.io/#JO.80stackA || (stackA = []);81stackB || (stackB = []);8283var length = stackA.length;84while (length--) {85if (stackA[length] == object) {86return stackB[length] == other;87}88}89// Add `object` and `other` to the stack of traversed objects.90stackA.push(object);91stackB.push(other);9293var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);9495stackA.pop();96stackB.pop();9798return result;99}100101module.exports = baseIsEqualDeep;102103104