fast-equals 1.6.3 → 2.0.3
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/BUILD.md +37 -0
- package/CHANGELOG.md +38 -0
- package/README.md +87 -106
- package/dist/fast-equals.cjs.js +291 -446
- package/dist/fast-equals.cjs.js.map +1 -1
- package/dist/fast-equals.esm.js +291 -446
- package/dist/fast-equals.esm.js.map +1 -1
- package/dist/fast-equals.js +295 -450
- package/dist/fast-equals.js.map +1 -1
- package/dist/fast-equals.min.js +1 -1
- package/dist/fast-equals.mjs +294 -0
- package/dist/fast-equals.mjs.map +1 -0
- package/index.d.ts +15 -14
- package/package.json +44 -63
- package/es/comparator.js +0 -86
- package/es/constants.js +0 -14
- package/es/index.js +0 -19
- package/es/utils.js +0 -333
- package/es-to-mjs.js +0 -14
- package/lib/comparator.js +0 -94
- package/lib/constants.js +0 -22
- package/lib/index.js +0 -36
- package/lib/utils.js +0 -386
- package/mjs/comparator.mjs +0 -86
- package/mjs/constants.mjs +0 -14
- package/mjs/index.mjs +0 -19
- package/mjs/utils.mjs +0 -333
- package/rollup.config.js +0 -55
- package/yarn-error.log +0 -8175
package/dist/fast-equals.cjs.js
CHANGED
|
@@ -2,457 +2,302 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @param
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
* @param
|
|
39
|
-
* @
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
* @
|
|
109
|
-
*
|
|
110
|
-
* @
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* @
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if (key === '_owner' && isReactElement(objectA) && isReactElement(objectB)) {
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (!isEqual(objectA[key], objectB[key], meta)) {
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return true;
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* @function areRegExpsEqual
|
|
311
|
-
*
|
|
312
|
-
* @description
|
|
313
|
-
* are the regExps equal in value
|
|
314
|
-
*
|
|
315
|
-
* @param {RegExp} regExpA the regExp to test
|
|
316
|
-
* @param {RegExp} regExpB the regExp to test agains
|
|
317
|
-
* @returns {boolean} are the regExps equal
|
|
318
|
-
*/
|
|
319
|
-
|
|
320
|
-
var areRegExpsEqual = function areRegExpsEqual(regExpA, regExpB) {
|
|
321
|
-
return regExpA.source === regExpB.source && regExpA.global === regExpB.global && regExpA.ignoreCase === regExpB.ignoreCase && regExpA.multiline === regExpB.multiline && regExpA.unicode === regExpB.unicode && regExpA.sticky === regExpB.sticky && regExpA.lastIndex === regExpB.lastIndex;
|
|
322
|
-
};
|
|
323
|
-
/**
|
|
324
|
-
* @function areSetsEqual
|
|
325
|
-
*
|
|
326
|
-
* @description
|
|
327
|
-
* are the sets equal in value
|
|
328
|
-
*
|
|
329
|
-
* @param {Set} setA the set to test
|
|
330
|
-
* @param {Set} setB the set to test against
|
|
331
|
-
* @param {function} isEqual the comparator to determine equality
|
|
332
|
-
* @param {any} meta the meta set to pass through
|
|
333
|
-
* @returns {boolean} are the sets equal
|
|
334
|
-
*/
|
|
335
|
-
|
|
336
|
-
var areSetsEqual = function areSetsEqual(setA, setB, isEqual, meta) {
|
|
337
|
-
if (setA.size !== setB.size) {
|
|
338
|
-
return false;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
var valuesA = toValues(setA);
|
|
342
|
-
var valuesB = toValues(setB);
|
|
343
|
-
|
|
344
|
-
for (var index = 0; index < valuesA.length; index++) {
|
|
345
|
-
if (!hasValue(valuesB, valuesA[index], isEqual, meta) || !hasValue(valuesA, valuesB[index], isEqual, meta)) {
|
|
346
|
-
return false;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return true;
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
// constants
|
|
354
|
-
var isArray = Array.isArray;
|
|
355
|
-
|
|
356
|
-
var createComparator = function createComparator(createIsEqual) {
|
|
357
|
-
// eslint-disable-next-line no-use-before-define
|
|
358
|
-
var isEqual = typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
|
|
359
|
-
/**
|
|
360
|
-
* @function comparator
|
|
361
|
-
*
|
|
362
|
-
* @description
|
|
363
|
-
* compare the value of the two objects and return true if they are equivalent in values
|
|
364
|
-
*
|
|
365
|
-
* @param {any} objectA the object to test against
|
|
366
|
-
* @param {any} objectB the object to test
|
|
367
|
-
* @param {any} [meta] an optional meta object that is passed through to all equality test calls
|
|
368
|
-
* @returns {boolean} are objectA and objectB equivalent in value
|
|
369
|
-
*/
|
|
370
|
-
|
|
371
|
-
function comparator(objectA, objectB, meta) {
|
|
372
|
-
if (sameValueZeroEqual(objectA, objectB)) {
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
var typeOfA = typeof objectA;
|
|
377
|
-
|
|
378
|
-
if (typeOfA !== typeof objectB || typeOfA !== 'object' || !objectA || !objectB) {
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
if (isPlainObject(objectA) && isPlainObject(objectB)) {
|
|
383
|
-
return areObjectsEqual(objectA, objectB, isEqual, meta);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
var arrayA = isArray(objectA);
|
|
387
|
-
var arrayB = isArray(objectB);
|
|
388
|
-
|
|
389
|
-
if (arrayA || arrayB) {
|
|
390
|
-
return arrayA === arrayB && areArraysEqual(objectA, objectB, isEqual, meta);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
var dateA = objectA instanceof Date;
|
|
394
|
-
var dateB = objectB instanceof Date;
|
|
395
|
-
|
|
396
|
-
if (dateA || dateB) {
|
|
397
|
-
return dateA === dateB && sameValueZeroEqual(objectA.getTime(), objectB.getTime());
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
var regexpA = objectA instanceof RegExp;
|
|
401
|
-
var regexpB = objectB instanceof RegExp;
|
|
402
|
-
|
|
403
|
-
if (regexpA || regexpB) {
|
|
404
|
-
return regexpA === regexpB && areRegExpsEqual(objectA, objectB);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (isPromiseLike(objectA) || isPromiseLike(objectB)) {
|
|
408
|
-
return objectA === objectB;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (HAS_MAP_SUPPORT) {
|
|
412
|
-
var mapA = objectA instanceof Map;
|
|
413
|
-
var mapB = objectB instanceof Map;
|
|
414
|
-
|
|
415
|
-
if (mapA || mapB) {
|
|
416
|
-
return mapA === mapB && areMapsEqual(objectA, objectB, isEqual, meta);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
if (HAS_SET_SUPPORT) {
|
|
421
|
-
var setA = objectA instanceof Set;
|
|
422
|
-
var setB = objectB instanceof Set;
|
|
423
|
-
|
|
424
|
-
if (setA || setB) {
|
|
425
|
-
return setA === setB && areSetsEqual(objectA, objectB, isEqual, meta);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
return areObjectsEqual(objectA, objectB, isEqual, meta);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return comparator;
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
// comparator
|
|
436
|
-
var circularDeepEqual = createComparator(createCircularEqual());
|
|
437
|
-
var circularShallowEqual = createComparator(createCircularEqual(sameValueZeroEqual));
|
|
438
|
-
var deepEqual = createComparator();
|
|
439
|
-
var shallowEqual = createComparator(function () {
|
|
440
|
-
return sameValueZeroEqual;
|
|
441
|
-
});
|
|
442
|
-
var index = {
|
|
443
|
-
circularDeep: circularDeepEqual,
|
|
444
|
-
circularShallow: circularShallowEqual,
|
|
445
|
-
createCustom: createComparator,
|
|
446
|
-
deep: deepEqual,
|
|
447
|
-
sameValueZero: sameValueZeroEqual,
|
|
448
|
-
shallow: shallowEqual
|
|
449
|
-
};
|
|
5
|
+
var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
|
|
6
|
+
var keys = Object.keys;
|
|
7
|
+
/**
|
|
8
|
+
* are the values passed strictly equal or both NaN
|
|
9
|
+
*
|
|
10
|
+
* @param a the value to compare against
|
|
11
|
+
* @param b the value to test
|
|
12
|
+
* @returns are the values equal by the SameValueZero principle
|
|
13
|
+
*/
|
|
14
|
+
function sameValueZeroEqual(a, b) {
|
|
15
|
+
return a === b || (a !== a && b !== b);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* is the value a plain object
|
|
19
|
+
*
|
|
20
|
+
* @param value the value to test
|
|
21
|
+
* @returns is the value a plain object
|
|
22
|
+
*/
|
|
23
|
+
function isPlainObject(value) {
|
|
24
|
+
return value.constructor === Object || value.constructor == null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* is the value promise-like (meaning it is thenable)
|
|
28
|
+
*
|
|
29
|
+
* @param value the value to test
|
|
30
|
+
* @returns is the value promise-like
|
|
31
|
+
*/
|
|
32
|
+
function isPromiseLike(value) {
|
|
33
|
+
return !!value && typeof value.then === 'function';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* is the value passed a react element
|
|
37
|
+
*
|
|
38
|
+
* @param value the value to test
|
|
39
|
+
* @returns is the value a react element
|
|
40
|
+
*/
|
|
41
|
+
function isReactElement(value) {
|
|
42
|
+
return !!(value && value.$$typeof);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* in cases where WeakSet is not supported, creates a new custom
|
|
46
|
+
* object that mimics the necessary API aspects for cache purposes
|
|
47
|
+
*
|
|
48
|
+
* @returns the new cache object
|
|
49
|
+
*/
|
|
50
|
+
function getNewCacheFallback() {
|
|
51
|
+
var values = [];
|
|
52
|
+
return {
|
|
53
|
+
add: function (value) {
|
|
54
|
+
values.push(value);
|
|
55
|
+
},
|
|
56
|
+
has: function (value) {
|
|
57
|
+
return values.indexOf(value) !== -1;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* get a new cache object to prevent circular references
|
|
63
|
+
*
|
|
64
|
+
* @returns the new cache object
|
|
65
|
+
*/
|
|
66
|
+
var getNewCache = (function (canUseWeakMap) {
|
|
67
|
+
if (canUseWeakMap) {
|
|
68
|
+
return function _getNewCache() {
|
|
69
|
+
return new WeakSet();
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return getNewCacheFallback;
|
|
73
|
+
})(HAS_WEAKSET_SUPPORT);
|
|
74
|
+
/**
|
|
75
|
+
* create a custom isEqual handler specific to circular objects
|
|
76
|
+
*
|
|
77
|
+
* @param [isEqual] the isEqual comparator to use instead of isDeepEqual
|
|
78
|
+
* @returns the method to create the `isEqual` function
|
|
79
|
+
*/
|
|
80
|
+
function createCircularEqualCreator(isEqual) {
|
|
81
|
+
return function createCircularEqual(comparator) {
|
|
82
|
+
var _comparator = isEqual || comparator;
|
|
83
|
+
return function circularEqual(a, b, cache) {
|
|
84
|
+
if (cache === void 0) { cache = getNewCache(); }
|
|
85
|
+
var isCacheableA = !!a && typeof a === 'object';
|
|
86
|
+
var isCacheableB = !!b && typeof b === 'object';
|
|
87
|
+
if (isCacheableA || isCacheableB) {
|
|
88
|
+
var hasA = isCacheableA && cache.has(a);
|
|
89
|
+
var hasB = isCacheableB && cache.has(b);
|
|
90
|
+
if (hasA || hasB) {
|
|
91
|
+
return hasA && hasB;
|
|
92
|
+
}
|
|
93
|
+
if (isCacheableA) {
|
|
94
|
+
cache.add(a);
|
|
95
|
+
}
|
|
96
|
+
if (isCacheableB) {
|
|
97
|
+
cache.add(b);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return _comparator(a, b, cache);
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* are the arrays equal in value
|
|
106
|
+
*
|
|
107
|
+
* @param a the array to test
|
|
108
|
+
* @param b the array to test against
|
|
109
|
+
* @param isEqual the comparator to determine equality
|
|
110
|
+
* @param meta the meta object to pass through
|
|
111
|
+
* @returns are the arrays equal
|
|
112
|
+
*/
|
|
113
|
+
function areArraysEqual(a, b, isEqual, meta) {
|
|
114
|
+
var index = a.length;
|
|
115
|
+
if (b.length !== index) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
while (index-- > 0) {
|
|
119
|
+
if (!isEqual(a[index], b[index], meta)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* are the maps equal in value
|
|
127
|
+
*
|
|
128
|
+
* @param a the map to test
|
|
129
|
+
* @param b the map to test against
|
|
130
|
+
* @param isEqual the comparator to determine equality
|
|
131
|
+
* @param meta the meta map to pass through
|
|
132
|
+
* @returns are the maps equal
|
|
133
|
+
*/
|
|
134
|
+
function areMapsEqual(a, b, isEqual, meta) {
|
|
135
|
+
var isValueEqual = a.size === b.size;
|
|
136
|
+
if (isValueEqual && a.size) {
|
|
137
|
+
a.forEach(function (aValue, aKey) {
|
|
138
|
+
if (isValueEqual) {
|
|
139
|
+
isValueEqual = false;
|
|
140
|
+
b.forEach(function (bValue, bKey) {
|
|
141
|
+
if (!isValueEqual && isEqual(aKey, bKey, meta)) {
|
|
142
|
+
isValueEqual = isEqual(aValue, bValue, meta);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return isValueEqual;
|
|
149
|
+
}
|
|
150
|
+
var OWNER = '_owner';
|
|
151
|
+
var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
|
|
152
|
+
/**
|
|
153
|
+
* are the objects equal in value
|
|
154
|
+
*
|
|
155
|
+
* @param a the object to test
|
|
156
|
+
* @param b the object to test against
|
|
157
|
+
* @param isEqual the comparator to determine equality
|
|
158
|
+
* @param meta the meta object to pass through
|
|
159
|
+
* @returns are the objects equal
|
|
160
|
+
*/
|
|
161
|
+
function areObjectsEqual(a, b, isEqual, meta) {
|
|
162
|
+
var keysA = keys(a);
|
|
163
|
+
var index = keysA.length;
|
|
164
|
+
if (keys(b).length !== index) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
if (index) {
|
|
168
|
+
var key = void 0;
|
|
169
|
+
while (index-- > 0) {
|
|
170
|
+
key = keysA[index];
|
|
171
|
+
if (key === OWNER) {
|
|
172
|
+
var reactElementA = isReactElement(a);
|
|
173
|
+
var reactElementB = isReactElement(b);
|
|
174
|
+
if ((reactElementA || reactElementB) &&
|
|
175
|
+
reactElementA !== reactElementB) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* are the regExps equal in value
|
|
188
|
+
*
|
|
189
|
+
* @param a the regExp to test
|
|
190
|
+
* @param b the regExp to test agains
|
|
191
|
+
* @returns are the regExps equal
|
|
192
|
+
*/
|
|
193
|
+
function areRegExpsEqual(a, b) {
|
|
194
|
+
return (a.source === b.source &&
|
|
195
|
+
a.global === b.global &&
|
|
196
|
+
a.ignoreCase === b.ignoreCase &&
|
|
197
|
+
a.multiline === b.multiline &&
|
|
198
|
+
a.unicode === b.unicode &&
|
|
199
|
+
a.sticky === b.sticky &&
|
|
200
|
+
a.lastIndex === b.lastIndex);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* are the sets equal in value
|
|
204
|
+
*
|
|
205
|
+
* @param a the set to test
|
|
206
|
+
* @param b the set to test against
|
|
207
|
+
* @param isEqual the comparator to determine equality
|
|
208
|
+
* @param meta the meta set to pass through
|
|
209
|
+
* @returns are the sets equal
|
|
210
|
+
*/
|
|
211
|
+
function areSetsEqual(a, b, isEqual, meta) {
|
|
212
|
+
var isValueEqual = a.size === b.size;
|
|
213
|
+
if (isValueEqual && a.size) {
|
|
214
|
+
a.forEach(function (aValue) {
|
|
215
|
+
if (isValueEqual) {
|
|
216
|
+
isValueEqual = false;
|
|
217
|
+
b.forEach(function (bValue) {
|
|
218
|
+
if (!isValueEqual) {
|
|
219
|
+
isValueEqual = isEqual(aValue, bValue, meta);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return isValueEqual;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var HAS_MAP_SUPPORT = typeof Map === 'function';
|
|
229
|
+
var HAS_SET_SUPPORT = typeof Set === 'function';
|
|
230
|
+
function createComparator(createIsEqual) {
|
|
231
|
+
var isEqual =
|
|
232
|
+
/* eslint-disable no-use-before-define */
|
|
233
|
+
typeof createIsEqual === 'function'
|
|
234
|
+
? createIsEqual(comparator)
|
|
235
|
+
: comparator;
|
|
236
|
+
/* eslint-enable */
|
|
237
|
+
/**
|
|
238
|
+
* compare the value of the two objects and return true if they are equivalent in values
|
|
239
|
+
*
|
|
240
|
+
* @param a the value to test against
|
|
241
|
+
* @param b the value to test
|
|
242
|
+
* @param [meta] an optional meta object that is passed through to all equality test calls
|
|
243
|
+
* @returns are a and b equivalent in value
|
|
244
|
+
*/
|
|
245
|
+
function comparator(a, b, meta) {
|
|
246
|
+
if (a === b) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
250
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
251
|
+
return areObjectsEqual(a, b, isEqual, meta);
|
|
252
|
+
}
|
|
253
|
+
var aShape = Array.isArray(a);
|
|
254
|
+
var bShape = Array.isArray(b);
|
|
255
|
+
if (aShape || bShape) {
|
|
256
|
+
return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
|
|
257
|
+
}
|
|
258
|
+
aShape = a instanceof Date;
|
|
259
|
+
bShape = b instanceof Date;
|
|
260
|
+
if (aShape || bShape) {
|
|
261
|
+
return (aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime()));
|
|
262
|
+
}
|
|
263
|
+
aShape = a instanceof RegExp;
|
|
264
|
+
bShape = b instanceof RegExp;
|
|
265
|
+
if (aShape || bShape) {
|
|
266
|
+
return aShape === bShape && areRegExpsEqual(a, b);
|
|
267
|
+
}
|
|
268
|
+
if (isPromiseLike(a) || isPromiseLike(b)) {
|
|
269
|
+
return a === b;
|
|
270
|
+
}
|
|
271
|
+
if (HAS_MAP_SUPPORT) {
|
|
272
|
+
aShape = a instanceof Map;
|
|
273
|
+
bShape = b instanceof Map;
|
|
274
|
+
if (aShape || bShape) {
|
|
275
|
+
return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (HAS_SET_SUPPORT) {
|
|
279
|
+
aShape = a instanceof Set;
|
|
280
|
+
bShape = b instanceof Set;
|
|
281
|
+
if (aShape || bShape) {
|
|
282
|
+
return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return areObjectsEqual(a, b, isEqual, meta);
|
|
286
|
+
}
|
|
287
|
+
return a !== a && b !== b;
|
|
288
|
+
}
|
|
289
|
+
return comparator;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
var deepEqual = createComparator();
|
|
293
|
+
var shallowEqual = createComparator(function () { return sameValueZeroEqual; });
|
|
294
|
+
var circularDeepEqual = createComparator(createCircularEqualCreator());
|
|
295
|
+
var circularShallowEqual = createComparator(createCircularEqualCreator(sameValueZeroEqual));
|
|
450
296
|
|
|
451
297
|
exports.circularDeepEqual = circularDeepEqual;
|
|
452
298
|
exports.circularShallowEqual = circularShallowEqual;
|
|
453
299
|
exports.createCustomEqual = createComparator;
|
|
454
300
|
exports.deepEqual = deepEqual;
|
|
455
|
-
exports.default = index;
|
|
456
301
|
exports.sameValueZeroEqual = sameValueZeroEqual;
|
|
457
302
|
exports.shallowEqual = shallowEqual;
|
|
458
303
|
//# sourceMappingURL=fast-equals.cjs.js.map
|