source: trip-planner-front/node_modules/lodash/_baseIsEqualDeep.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.9 KB
Line 
1var 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');
9
10/** Used to compose bitmasks for value comparisons. */
11var COMPARE_PARTIAL_FLAG = 1;
12
13/** `Object#toString` result references. */
14var argsTag = '[object Arguments]',
15 arrayTag = '[object Array]',
16 objectTag = '[object Object]';
17
18/** Used for built-in method references. */
19var objectProto = Object.prototype;
20
21/** Used to check objects for own properties. */
22var hasOwnProperty = objectProto.hasOwnProperty;
23
24/**
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.
28 *
29 * @private
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`.
37 */
38function 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);
43
44 objTag = objTag == argsTag ? objectTag : objTag;
45 othTag = othTag == argsTag ? objectTag : othTag;
46
47 var objIsObj = objTag == objectTag,
48 othIsObj = othTag == objectTag,
49 isSameTag = objTag == othTag;
50
51 if (isSameTag && isBuffer(object)) {
52 if (!isBuffer(other)) {
53 return false;
54 }
55 objIsArr = true;
56 objIsObj = false;
57 }
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);
63 }
64 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
65 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
66 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
67
68 if (objIsWrapped || othIsWrapped) {
69 var objUnwrapped = objIsWrapped ? object.value() : object,
70 othUnwrapped = othIsWrapped ? other.value() : other;
71
72 stack || (stack = new Stack);
73 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
74 }
75 }
76 if (!isSameTag) {
77 return false;
78 }
79 stack || (stack = new Stack);
80 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
81}
82
83module.exports = baseIsEqualDeep;
Note: See TracBrowser for help on using the repository browser.