1 | import Stack from './_Stack';
|
2 | import equalArrays from './_equalArrays';
|
3 | import equalByTag from './_equalByTag';
|
4 | import equalObjects from './_equalObjects';
|
5 | import getTag from './_getTag';
|
6 | import isArray from './isArray';
|
7 | import isHostObject from './_isHostObject';
|
8 | import isTypedArray from './isTypedArray';
|
9 |
|
10 |
|
11 | var PARTIAL_COMPARE_FLAG = 2;
|
12 |
|
13 |
|
14 | var argsTag = '[object Arguments]',
|
15 | arrayTag = '[object Array]',
|
16 | objectTag = '[object Object]';
|
17 |
|
18 |
|
19 | var objectProto = Object.prototype;
|
20 |
|
21 |
|
22 | var hasOwnProperty = objectProto.hasOwnProperty;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
40 | var objIsArr = isArray(object),
|
41 | othIsArr = isArray(other),
|
42 | objTag = arrayTag,
|
43 | othTag = arrayTag;
|
44 |
|
45 | if (!objIsArr) {
|
46 | objTag = getTag(object);
|
47 | objTag = objTag == argsTag ? objectTag : objTag;
|
48 | }
|
49 | if (!othIsArr) {
|
50 | othTag = getTag(other);
|
51 | othTag = othTag == argsTag ? objectTag : othTag;
|
52 | }
|
53 | var objIsObj = objTag == objectTag && !isHostObject(object),
|
54 | othIsObj = othTag == objectTag && !isHostObject(other),
|
55 | isSameTag = objTag == othTag;
|
56 |
|
57 | if (isSameTag && !objIsObj) {
|
58 | stack || (stack = new Stack);
|
59 | return (objIsArr || isTypedArray(object))
|
60 | ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
|
61 | : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
|
62 | }
|
63 | if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
|
64 | var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
65 | othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
66 |
|
67 | if (objIsWrapped || othIsWrapped) {
|
68 | var objUnwrapped = objIsWrapped ? object.value() : object,
|
69 | othUnwrapped = othIsWrapped ? other.value() : other;
|
70 |
|
71 | stack || (stack = new Stack);
|
72 | return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
|
73 | }
|
74 | }
|
75 | if (!isSameTag) {
|
76 | return false;
|
77 | }
|
78 | stack || (stack = new Stack);
|
79 | return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
|
80 | }
|
81 |
|
82 | export default baseIsEqualDeep;
|