ut2 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ut2.js +8 -9
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/internals/helpers.js +1 -1
- package/es/internals/isEqualDeep.js +178 -0
- package/es/isEqual.js +1 -175
- package/es/isMatch.js +7 -9
- package/lib/internals/helpers.js +1 -1
- package/lib/internals/isEqualDeep.js +180 -0
- package/lib/isEqual.js +1 -175
- package/lib/isMatch.js +7 -9
- package/package.json +1 -1
- package/types/internals/isEqualDeep.d.ts +26 -0
- package/types/isEqual.d.ts +2 -2
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import allKeys from '../allKeys.js';
|
|
2
|
+
import eq from '../eq.js';
|
|
3
|
+
import getTagWithBugfix from './getTagWithBugfix.js';
|
|
4
|
+
import { symbolProto, arrayBufferTag, dataViewTag, errorTag, symbolTag, regExpTag, stringTag, dateTag, booleanTag, numberTag, objectTag, objectProtoHasOwnProperty, argumentsTag, setTag, mapTag, arrayTag, arrayProtoSlice } from './native.js';
|
|
5
|
+
import isBuffer from '../isBuffer.js';
|
|
6
|
+
import isFunction from '../isFunction.js';
|
|
7
|
+
import isNil from '../isNil.js';
|
|
8
|
+
import isObjectLike from '../isObjectLike.js';
|
|
9
|
+
import isTypedArray from '../isTypedArray.js';
|
|
10
|
+
import orderBy from '../orderBy.js';
|
|
11
|
+
|
|
12
|
+
var symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
13
|
+
function mapToArray(map) {
|
|
14
|
+
var result = [];
|
|
15
|
+
map.forEach(function (value, key) {
|
|
16
|
+
result.push([key, value]);
|
|
17
|
+
});
|
|
18
|
+
return orderBy(result, [0, 1]);
|
|
19
|
+
}
|
|
20
|
+
function setToArray(set) {
|
|
21
|
+
var result = [];
|
|
22
|
+
set.forEach(function (value) {
|
|
23
|
+
result.push(value);
|
|
24
|
+
});
|
|
25
|
+
return orderBy(result);
|
|
26
|
+
}
|
|
27
|
+
function argToArray(arg) {
|
|
28
|
+
return arrayProtoSlice.call(arg);
|
|
29
|
+
}
|
|
30
|
+
function toBufferView(bufferSource) {
|
|
31
|
+
return new Uint8Array(bufferSource.buffer || bufferSource, bufferSource.byteOffset || 0, bufferSource.byteLength);
|
|
32
|
+
}
|
|
33
|
+
function isDomNode(obj) {
|
|
34
|
+
return isObjectLike(obj) && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string' && typeof obj.isEqualNode === 'function';
|
|
35
|
+
}
|
|
36
|
+
function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherStack) {
|
|
37
|
+
if (eq(value, other, strictCheck)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
var valType = typeof value;
|
|
41
|
+
var othType = typeof other;
|
|
42
|
+
if (strictCheck && valType !== othType) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (isNil(value) || isNil(other) || (valType !== 'object' && othType !== 'object')) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
var tag = getTagWithBugfix(value);
|
|
49
|
+
if (tag !== getTagWithBugfix(other)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
var convert;
|
|
53
|
+
switch (tag) {
|
|
54
|
+
case numberTag:
|
|
55
|
+
return eq(+value, +other, strictCheck);
|
|
56
|
+
case booleanTag:
|
|
57
|
+
case dateTag:
|
|
58
|
+
return strictCheck ? +value === +other : eq(+value, +other);
|
|
59
|
+
case stringTag:
|
|
60
|
+
case regExpTag:
|
|
61
|
+
return '' + value === '' + other;
|
|
62
|
+
case symbolTag:
|
|
63
|
+
return symbolValueOf ? symbolValueOf.call(value) === symbolValueOf.call(other) : false;
|
|
64
|
+
case errorTag:
|
|
65
|
+
return value.name === other.name && value.message === other.message;
|
|
66
|
+
case dataViewTag:
|
|
67
|
+
case arrayBufferTag:
|
|
68
|
+
if (value.byteLength !== other.byteLength || (value.byteOffset && value.byteOffset !== other.byteOffset)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
convert = toBufferView;
|
|
72
|
+
break;
|
|
73
|
+
case mapTag:
|
|
74
|
+
convert = mapToArray;
|
|
75
|
+
break;
|
|
76
|
+
case setTag:
|
|
77
|
+
convert = setToArray;
|
|
78
|
+
break;
|
|
79
|
+
case argumentsTag:
|
|
80
|
+
convert = argToArray;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (convert) {
|
|
84
|
+
return isEqualDeep(convert(value), convert(other), customizer, strictCheck, valueStack, otherStack);
|
|
85
|
+
}
|
|
86
|
+
if (isDomNode(value) && isDomNode(other)) {
|
|
87
|
+
return value.isEqualNode(other);
|
|
88
|
+
}
|
|
89
|
+
var areArrays = tag === arrayTag;
|
|
90
|
+
if (!areArrays && isTypedArray(value)) {
|
|
91
|
+
if (value.byteLength !== other.byteLength) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
if (value.buffer === other.buffer && value.byteOffset === other.byteOffset) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
areArrays = true;
|
|
98
|
+
}
|
|
99
|
+
if (isBuffer(value)) {
|
|
100
|
+
if (!isBuffer(other)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
areArrays = true;
|
|
104
|
+
}
|
|
105
|
+
valueStack = valueStack || [];
|
|
106
|
+
otherStack = otherStack || [];
|
|
107
|
+
var length = valueStack.length;
|
|
108
|
+
while (length--) {
|
|
109
|
+
if (valueStack[length] === value) {
|
|
110
|
+
return otherStack[length] === other;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
valueStack.push(value);
|
|
114
|
+
otherStack.push(other);
|
|
115
|
+
var result = true;
|
|
116
|
+
var hasCustomizer = typeof customizer === 'function';
|
|
117
|
+
if (areArrays) {
|
|
118
|
+
length = value.length;
|
|
119
|
+
if (length !== other.length) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
while (length--) {
|
|
123
|
+
if (hasCustomizer) {
|
|
124
|
+
var compared = customizer(value[length], other[length], length, value, other, valueStack, otherStack);
|
|
125
|
+
if (compared !== undefined) {
|
|
126
|
+
if (!compared) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!isEqualDeep(value[length], other[length], customizer, strictCheck, valueStack, otherStack)) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (tag === objectTag) {
|
|
138
|
+
var keys = allKeys(value);
|
|
139
|
+
length = keys.length;
|
|
140
|
+
if (allKeys(other).length !== length) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
var skipCtor = false;
|
|
144
|
+
while (length--) {
|
|
145
|
+
var key = keys[length];
|
|
146
|
+
if (hasCustomizer) {
|
|
147
|
+
var compared = customizer(value[key], other[key], key, value, other, valueStack, otherStack);
|
|
148
|
+
if (compared !== undefined) {
|
|
149
|
+
if (!compared) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!(objectProtoHasOwnProperty.call(other, key) && isEqualDeep(value[key], other[key], customizer, strictCheck, valueStack, otherStack))) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
if (!skipCtor && key === 'constructor') {
|
|
159
|
+
skipCtor = true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!skipCtor) {
|
|
163
|
+
var valCtor = value.constructor;
|
|
164
|
+
var othCtor = other.constructor;
|
|
165
|
+
if (valCtor !== othCtor && !(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) && 'constructor' in value && 'constructor' in other) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
result = false;
|
|
172
|
+
}
|
|
173
|
+
valueStack.pop();
|
|
174
|
+
otherStack.pop();
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export { isEqualDeep as default };
|
package/es/isEqual.js
CHANGED
|
@@ -1,179 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import eq from './eq.js';
|
|
3
|
-
import getTagWithBugfix from './internals/getTagWithBugfix.js';
|
|
4
|
-
import { symbolProto, arrayBufferTag, dataViewTag, errorTag, symbolTag, regExpTag, stringTag, dateTag, booleanTag, numberTag, objectTag, objectProtoHasOwnProperty, argumentsTag, setTag, mapTag, arrayTag, arrayProtoSlice } from './internals/native.js';
|
|
5
|
-
import isBuffer from './isBuffer.js';
|
|
6
|
-
import isFunction from './isFunction.js';
|
|
7
|
-
import isNil from './isNil.js';
|
|
8
|
-
import isObjectLike from './isObjectLike.js';
|
|
9
|
-
import isTypedArray from './isTypedArray.js';
|
|
10
|
-
import orderBy from './orderBy.js';
|
|
1
|
+
import isEqualDeep from './internals/isEqualDeep.js';
|
|
11
2
|
|
|
12
|
-
var symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
13
|
-
function mapToArray(map) {
|
|
14
|
-
var result = [];
|
|
15
|
-
map.forEach(function (value, key) {
|
|
16
|
-
result.push([key, value]);
|
|
17
|
-
});
|
|
18
|
-
return orderBy(result, [0, 1]);
|
|
19
|
-
}
|
|
20
|
-
function setToArray(set) {
|
|
21
|
-
var result = [];
|
|
22
|
-
set.forEach(function (value) {
|
|
23
|
-
result.push(value);
|
|
24
|
-
});
|
|
25
|
-
return orderBy(result);
|
|
26
|
-
}
|
|
27
|
-
function argToArray(arg) {
|
|
28
|
-
return arrayProtoSlice.call(arg);
|
|
29
|
-
}
|
|
30
|
-
function toBufferView(bufferSource) {
|
|
31
|
-
return new Uint8Array(bufferSource.buffer || bufferSource, bufferSource.byteOffset || 0, bufferSource.byteLength);
|
|
32
|
-
}
|
|
33
|
-
function isDomNode(obj) {
|
|
34
|
-
return isObjectLike(obj) && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string' && typeof obj.isEqualNode === 'function';
|
|
35
|
-
}
|
|
36
|
-
function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherStack) {
|
|
37
|
-
if (eq(value, other, strictCheck)) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
var valType = typeof value;
|
|
41
|
-
var othType = typeof other;
|
|
42
|
-
if (strictCheck && valType !== othType) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
if (isNil(value) || isNil(other) || (valType !== 'object' && othType !== 'object')) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
var tag = getTagWithBugfix(value);
|
|
49
|
-
if (tag !== getTagWithBugfix(other)) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
var convert;
|
|
53
|
-
switch (tag) {
|
|
54
|
-
case numberTag:
|
|
55
|
-
return eq(+value, +other, strictCheck);
|
|
56
|
-
case booleanTag:
|
|
57
|
-
case dateTag:
|
|
58
|
-
return strictCheck ? +value === +other : eq(+value, +other);
|
|
59
|
-
case stringTag:
|
|
60
|
-
case regExpTag:
|
|
61
|
-
return '' + value === '' + other;
|
|
62
|
-
case symbolTag:
|
|
63
|
-
return symbolValueOf ? symbolValueOf.call(value) === symbolValueOf.call(other) : false;
|
|
64
|
-
case errorTag:
|
|
65
|
-
return value.name === other.name && value.message === other.message;
|
|
66
|
-
case dataViewTag:
|
|
67
|
-
case arrayBufferTag:
|
|
68
|
-
if (value.byteLength !== other.byteLength || (value.byteOffset && value.byteOffset !== other.byteOffset)) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
convert = toBufferView;
|
|
72
|
-
break;
|
|
73
|
-
case mapTag:
|
|
74
|
-
convert = mapToArray;
|
|
75
|
-
break;
|
|
76
|
-
case setTag:
|
|
77
|
-
convert = setToArray;
|
|
78
|
-
break;
|
|
79
|
-
case argumentsTag:
|
|
80
|
-
convert = argToArray;
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
if (convert) {
|
|
84
|
-
return isEqualDeep(convert(value), convert(other), customizer, strictCheck, valueStack, otherStack);
|
|
85
|
-
}
|
|
86
|
-
if (isDomNode(value) && isDomNode(other)) {
|
|
87
|
-
return value.isEqualNode(other);
|
|
88
|
-
}
|
|
89
|
-
var areArrays = tag === arrayTag;
|
|
90
|
-
if (!areArrays && isTypedArray(value)) {
|
|
91
|
-
if (value.byteLength !== other.byteLength) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
if (value.buffer === other.buffer && value.byteOffset === other.byteOffset) {
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
areArrays = true;
|
|
98
|
-
}
|
|
99
|
-
if (isBuffer(value)) {
|
|
100
|
-
if (!isBuffer(other)) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
areArrays = true;
|
|
104
|
-
}
|
|
105
|
-
valueStack = valueStack || [];
|
|
106
|
-
otherStack = otherStack || [];
|
|
107
|
-
var length = valueStack.length;
|
|
108
|
-
while (length--) {
|
|
109
|
-
if (valueStack[length] === value) {
|
|
110
|
-
return otherStack[length] === other;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
valueStack.push(value);
|
|
114
|
-
otherStack.push(other);
|
|
115
|
-
var result = true;
|
|
116
|
-
var hasCustomizer = typeof customizer === 'function';
|
|
117
|
-
if (areArrays) {
|
|
118
|
-
length = value.length;
|
|
119
|
-
if (length !== other.length) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
while (length--) {
|
|
123
|
-
if (hasCustomizer) {
|
|
124
|
-
var compared = customizer(value[length], other[length], length, value, other, valueStack, otherStack);
|
|
125
|
-
if (compared !== undefined) {
|
|
126
|
-
if (!compared) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (!isEqualDeep(value[length], other[length], customizer, strictCheck, valueStack, otherStack)) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else if (tag === objectTag) {
|
|
138
|
-
var keys = allKeys(value);
|
|
139
|
-
length = keys.length;
|
|
140
|
-
if (allKeys(other).length !== length) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
var skipCtor = false;
|
|
144
|
-
while (length--) {
|
|
145
|
-
var key = keys[length];
|
|
146
|
-
if (hasCustomizer) {
|
|
147
|
-
var compared = customizer(value[key], other[key], key, value, other, valueStack, otherStack);
|
|
148
|
-
if (compared !== undefined) {
|
|
149
|
-
if (!compared) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (!(objectProtoHasOwnProperty.call(other, key) && isEqualDeep(value[key], other[key], customizer, strictCheck, valueStack, otherStack))) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
if (!skipCtor && key === 'constructor') {
|
|
159
|
-
skipCtor = true;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (!skipCtor) {
|
|
163
|
-
var valCtor = value.constructor;
|
|
164
|
-
var othCtor = other.constructor;
|
|
165
|
-
if (valCtor !== othCtor && !(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) && 'constructor' in value && 'constructor' in other) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
result = false;
|
|
172
|
-
}
|
|
173
|
-
valueStack.pop();
|
|
174
|
-
otherStack.pop();
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
3
|
function isEqual(value, other, customizer, strictCheck) {
|
|
178
4
|
if (strictCheck === void 0) { strictCheck = false; }
|
|
179
5
|
if (typeof customizer === 'function') {
|
package/es/isMatch.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import allKeys from './allKeys.js';
|
|
2
2
|
import getTag from './internals/getTag.js';
|
|
3
3
|
import { objectTag } from './internals/native.js';
|
|
4
|
-
import
|
|
4
|
+
import isEqualDeep from './internals/isEqualDeep.js';
|
|
5
5
|
|
|
6
6
|
function isDeepComparable(object, source) {
|
|
7
7
|
return getTag(object) === objectTag && getTag(source) === objectTag;
|
|
8
8
|
}
|
|
9
|
-
function baseIsMatch(object, source, customizer, strictCheck, objStack, srcStack
|
|
10
|
-
if (executedCustomizer === void 0) { executedCustomizer = false; }
|
|
9
|
+
function baseIsMatch(object, source, customizer, strictCheck, objStack, srcStack) {
|
|
11
10
|
var hasCustomizer = typeof customizer === 'function';
|
|
12
11
|
if (isDeepComparable(object, source)) {
|
|
13
12
|
objStack = objStack || [];
|
|
@@ -36,7 +35,7 @@ function baseIsMatch(object, source, customizer, strictCheck, objStack, srcStack
|
|
|
36
35
|
continue;
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
if (!baseIsMatch(object[key], source[key], customizer, strictCheck, objStack, srcStack
|
|
38
|
+
if (!baseIsMatch(object[key], source[key], customizer, strictCheck, objStack, srcStack)) {
|
|
40
39
|
return false;
|
|
41
40
|
}
|
|
42
41
|
}
|
|
@@ -44,18 +43,17 @@ function baseIsMatch(object, source, customizer, strictCheck, objStack, srcStack
|
|
|
44
43
|
srcStack.pop();
|
|
45
44
|
return true;
|
|
46
45
|
}
|
|
47
|
-
var result =
|
|
48
|
-
if (
|
|
46
|
+
var result = isEqualDeep(object, source, function (objValue, srcValue, k, obj, src) {
|
|
47
|
+
if (hasCustomizer) {
|
|
49
48
|
var compared = customizer(objValue, srcValue, k, obj, src, objStack, srcStack);
|
|
50
49
|
if (compared !== undefined) {
|
|
51
50
|
return compared;
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
executedCustomizer = false;
|
|
55
53
|
if (isDeepComparable(objValue, srcValue)) {
|
|
56
54
|
return baseIsMatch(objValue, srcValue, customizer, strictCheck, objStack, srcStack);
|
|
57
55
|
}
|
|
58
|
-
}, strictCheck);
|
|
56
|
+
}, strictCheck, objStack, srcStack);
|
|
59
57
|
return result;
|
|
60
58
|
}
|
|
61
59
|
function isMatch(object, source, customizer, strictCheck) {
|
|
@@ -66,7 +64,7 @@ function isMatch(object, source, customizer, strictCheck) {
|
|
|
66
64
|
return !!compared;
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
|
-
return baseIsMatch(object, source, customizer, strictCheck, undefined, undefined
|
|
67
|
+
return baseIsMatch(object, source, customizer, strictCheck, undefined, undefined);
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
export { isMatch as default };
|
package/lib/internals/helpers.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var getTag = require('./getTag.js');
|
|
4
4
|
var native = require('./native.js');
|
|
5
5
|
|
|
6
|
-
exports.VERSION = "1.5.
|
|
6
|
+
exports.VERSION = "1.5.4";
|
|
7
7
|
exports.supportedArgumentsType = getTag((function () { return arguments; })()) === native.argumentsTag;
|
|
8
8
|
exports.FUNC_ERROR_TEXT = 'Expected a function';
|
|
9
9
|
function toSource(func) {
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var allKeys = require('../allKeys.js');
|
|
4
|
+
var eq = require('../eq.js');
|
|
5
|
+
var getTagWithBugfix = require('./getTagWithBugfix.js');
|
|
6
|
+
var native = require('./native.js');
|
|
7
|
+
var isBuffer = require('../isBuffer.js');
|
|
8
|
+
var isFunction = require('../isFunction.js');
|
|
9
|
+
var isNil = require('../isNil.js');
|
|
10
|
+
var isObjectLike = require('../isObjectLike.js');
|
|
11
|
+
var isTypedArray = require('../isTypedArray.js');
|
|
12
|
+
var orderBy = require('../orderBy.js');
|
|
13
|
+
|
|
14
|
+
var symbolValueOf = native.symbolProto ? native.symbolProto.valueOf : undefined;
|
|
15
|
+
function mapToArray(map) {
|
|
16
|
+
var result = [];
|
|
17
|
+
map.forEach(function (value, key) {
|
|
18
|
+
result.push([key, value]);
|
|
19
|
+
});
|
|
20
|
+
return orderBy(result, [0, 1]);
|
|
21
|
+
}
|
|
22
|
+
function setToArray(set) {
|
|
23
|
+
var result = [];
|
|
24
|
+
set.forEach(function (value) {
|
|
25
|
+
result.push(value);
|
|
26
|
+
});
|
|
27
|
+
return orderBy(result);
|
|
28
|
+
}
|
|
29
|
+
function argToArray(arg) {
|
|
30
|
+
return native.arrayProtoSlice.call(arg);
|
|
31
|
+
}
|
|
32
|
+
function toBufferView(bufferSource) {
|
|
33
|
+
return new Uint8Array(bufferSource.buffer || bufferSource, bufferSource.byteOffset || 0, bufferSource.byteLength);
|
|
34
|
+
}
|
|
35
|
+
function isDomNode(obj) {
|
|
36
|
+
return isObjectLike(obj) && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string' && typeof obj.isEqualNode === 'function';
|
|
37
|
+
}
|
|
38
|
+
function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherStack) {
|
|
39
|
+
if (eq(value, other, strictCheck)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
var valType = typeof value;
|
|
43
|
+
var othType = typeof other;
|
|
44
|
+
if (strictCheck && valType !== othType) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
if (isNil(value) || isNil(other) || (valType !== 'object' && othType !== 'object')) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
var tag = getTagWithBugfix(value);
|
|
51
|
+
if (tag !== getTagWithBugfix(other)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
var convert;
|
|
55
|
+
switch (tag) {
|
|
56
|
+
case native.numberTag:
|
|
57
|
+
return eq(+value, +other, strictCheck);
|
|
58
|
+
case native.booleanTag:
|
|
59
|
+
case native.dateTag:
|
|
60
|
+
return strictCheck ? +value === +other : eq(+value, +other);
|
|
61
|
+
case native.stringTag:
|
|
62
|
+
case native.regExpTag:
|
|
63
|
+
return '' + value === '' + other;
|
|
64
|
+
case native.symbolTag:
|
|
65
|
+
return symbolValueOf ? symbolValueOf.call(value) === symbolValueOf.call(other) : false;
|
|
66
|
+
case native.errorTag:
|
|
67
|
+
return value.name === other.name && value.message === other.message;
|
|
68
|
+
case native.dataViewTag:
|
|
69
|
+
case native.arrayBufferTag:
|
|
70
|
+
if (value.byteLength !== other.byteLength || (value.byteOffset && value.byteOffset !== other.byteOffset)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
convert = toBufferView;
|
|
74
|
+
break;
|
|
75
|
+
case native.mapTag:
|
|
76
|
+
convert = mapToArray;
|
|
77
|
+
break;
|
|
78
|
+
case native.setTag:
|
|
79
|
+
convert = setToArray;
|
|
80
|
+
break;
|
|
81
|
+
case native.argumentsTag:
|
|
82
|
+
convert = argToArray;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (convert) {
|
|
86
|
+
return isEqualDeep(convert(value), convert(other), customizer, strictCheck, valueStack, otherStack);
|
|
87
|
+
}
|
|
88
|
+
if (isDomNode(value) && isDomNode(other)) {
|
|
89
|
+
return value.isEqualNode(other);
|
|
90
|
+
}
|
|
91
|
+
var areArrays = tag === native.arrayTag;
|
|
92
|
+
if (!areArrays && isTypedArray(value)) {
|
|
93
|
+
if (value.byteLength !== other.byteLength) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (value.buffer === other.buffer && value.byteOffset === other.byteOffset) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
areArrays = true;
|
|
100
|
+
}
|
|
101
|
+
if (isBuffer(value)) {
|
|
102
|
+
if (!isBuffer(other)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
areArrays = true;
|
|
106
|
+
}
|
|
107
|
+
valueStack = valueStack || [];
|
|
108
|
+
otherStack = otherStack || [];
|
|
109
|
+
var length = valueStack.length;
|
|
110
|
+
while (length--) {
|
|
111
|
+
if (valueStack[length] === value) {
|
|
112
|
+
return otherStack[length] === other;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
valueStack.push(value);
|
|
116
|
+
otherStack.push(other);
|
|
117
|
+
var result = true;
|
|
118
|
+
var hasCustomizer = typeof customizer === 'function';
|
|
119
|
+
if (areArrays) {
|
|
120
|
+
length = value.length;
|
|
121
|
+
if (length !== other.length) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
while (length--) {
|
|
125
|
+
if (hasCustomizer) {
|
|
126
|
+
var compared = customizer(value[length], other[length], length, value, other, valueStack, otherStack);
|
|
127
|
+
if (compared !== undefined) {
|
|
128
|
+
if (!compared) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!isEqualDeep(value[length], other[length], customizer, strictCheck, valueStack, otherStack)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (tag === native.objectTag) {
|
|
140
|
+
var keys = allKeys(value);
|
|
141
|
+
length = keys.length;
|
|
142
|
+
if (allKeys(other).length !== length) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
var skipCtor = false;
|
|
146
|
+
while (length--) {
|
|
147
|
+
var key = keys[length];
|
|
148
|
+
if (hasCustomizer) {
|
|
149
|
+
var compared = customizer(value[key], other[key], key, value, other, valueStack, otherStack);
|
|
150
|
+
if (compared !== undefined) {
|
|
151
|
+
if (!compared) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!(native.objectProtoHasOwnProperty.call(other, key) && isEqualDeep(value[key], other[key], customizer, strictCheck, valueStack, otherStack))) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
if (!skipCtor && key === 'constructor') {
|
|
161
|
+
skipCtor = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (!skipCtor) {
|
|
165
|
+
var valCtor = value.constructor;
|
|
166
|
+
var othCtor = other.constructor;
|
|
167
|
+
if (valCtor !== othCtor && !(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) && 'constructor' in value && 'constructor' in other) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
result = false;
|
|
174
|
+
}
|
|
175
|
+
valueStack.pop();
|
|
176
|
+
otherStack.pop();
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
module.exports = isEqualDeep;
|