fast-equals 6.0.2 → 6.0.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 +4 -2
- package/dist/cjs/index.cjs +84 -14
- package/dist/es/index.mjs +84 -14
- package/package.json +20 -20
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
> fast-equals
|
|
2
2
|
|
|
3
3
|
Perform [blazing fast](#benchmarks) equality comparisons between two objects, while also allowing for flexibility for
|
|
4
|
-
various use-cases. It has no dependencies, and is ~
|
|
4
|
+
various use-cases. It has no dependencies, and is ~2.3kB when minified and gzipped.
|
|
5
5
|
|
|
6
6
|
The following types are handled out-of-the-box:
|
|
7
7
|
|
|
@@ -12,7 +12,9 @@ The following types are handled out-of-the-box:
|
|
|
12
12
|
- `RegExp` objects
|
|
13
13
|
- `Map` / `Set` iterables
|
|
14
14
|
- `Promise` objects and then-ables
|
|
15
|
-
-
|
|
15
|
+
- `Error` objects, including subclasses and their own properties
|
|
16
|
+
- `URL` objects
|
|
17
|
+
- Primitive wrappers (`new Boolean()` / `new Number()` / `new String()`, and boxed `BigInt`)
|
|
16
18
|
- Custom class instances, including subclasses of native classes
|
|
17
19
|
|
|
18
20
|
Methods are available for deep, shallow, [`SameValue`](http://ecma-international.org/ecma-262/7.0/#sec-samevalue),
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
5
4
|
const { hasOwnProperty } = Object.prototype;
|
|
6
5
|
/**
|
|
7
6
|
* Combine two comparators into a single comparators.
|
|
@@ -55,6 +54,9 @@ Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property));
|
|
|
55
54
|
const PREACT_VNODE = '__v';
|
|
56
55
|
const PREACT_OWNER = '__o';
|
|
57
56
|
const REACT_OWNER = '_owner';
|
|
57
|
+
// `Float16Array` is recent enough that it cannot be referenced unguarded, and capturing its
|
|
58
|
+
// availability once keeps that detail out of the comparison itself.
|
|
59
|
+
const HAS_FLOAT_16_ARRAY = typeof Float16Array !== 'undefined';
|
|
58
60
|
const { getOwnPropertyDescriptor, keys } = Object;
|
|
59
61
|
/**
|
|
60
62
|
* Whether the values passed are equal based on a [SameValue](https://262.ecma-international.org/7.0/#sec-samevalue) basis.
|
|
@@ -126,9 +128,19 @@ function areDatesEqual(a, b) {
|
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
128
130
|
* Whether the errors passed are equal in value.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
*
|
|
132
|
+
* @note
|
|
133
|
+
* `name`, `message` and `stack` are own properties but are not enumerable, so they are compared
|
|
134
|
+
* explicitly. `cause` is compared by value rather than by reference, matching how every other
|
|
135
|
+
* nested value in the comparison is treated. Own enumerable properties (which custom `Error`
|
|
136
|
+
* subclasses commonly add) are compared by composing this with the object comparator in the
|
|
137
|
+
* comparator config, so that the strict and circular variants apply to them as well.
|
|
138
|
+
*/
|
|
139
|
+
function areErrorsEqual(a, b, state) {
|
|
140
|
+
return (a.name === b.name
|
|
141
|
+
&& a.message === b.message
|
|
142
|
+
&& a.stack === b.stack
|
|
143
|
+
&& state.equals(a.cause, b.cause, 'cause', 'cause', a, b, state));
|
|
132
144
|
}
|
|
133
145
|
/**
|
|
134
146
|
* Whether the `Map`s are equal in value.
|
|
@@ -294,6 +306,19 @@ function areTypedArraysEqual(a, b) {
|
|
|
294
306
|
if (b.length !== index || a.byteOffset !== b.byteOffset) {
|
|
295
307
|
return false;
|
|
296
308
|
}
|
|
309
|
+
// Only float-backed views can hold `NaN`, and the additional check needed to treat it as equal
|
|
310
|
+
// to itself measurably slows the loop, so integer views keep the plain comparison. This is
|
|
311
|
+
// hoisted out of the loop so the cost is paid once per call rather than once per element.
|
|
312
|
+
if (a instanceof Float64Array || a instanceof Float32Array || (HAS_FLOAT_16_ARRAY && a instanceof Float16Array)) {
|
|
313
|
+
while (index-- > 0) {
|
|
314
|
+
// `NaN` is the only value not equal to itself, and it is treated as equal here to match
|
|
315
|
+
// the SameValueZero semantics used for every other numeric comparison in the library.
|
|
316
|
+
if (a[index] !== b[index] && (a[index] === a[index] || b[index] === b[index])) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
297
322
|
while (index-- > 0) {
|
|
298
323
|
if (a[index] !== b[index]) {
|
|
299
324
|
return false;
|
|
@@ -305,13 +330,45 @@ function areTypedArraysEqual(a, b) {
|
|
|
305
330
|
* Whether the URL instances are equal in value.
|
|
306
331
|
*/
|
|
307
332
|
function areUrlsEqual(a, b) {
|
|
308
|
-
|
|
333
|
+
// `href` is the normalized serialization of every component, so matching hrefs are equal without
|
|
334
|
+
// any further work. Only a difference in query parameter ordering can survive a mismatch here.
|
|
335
|
+
if (a.href === b.href) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
return (a.protocol === b.protocol
|
|
339
|
+
&& a.username === b.username
|
|
340
|
+
&& a.password === b.password
|
|
341
|
+
// `host` covers both the hostname and the port.
|
|
342
|
+
&& a.host === b.host
|
|
309
343
|
&& a.pathname === b.pathname
|
|
310
|
-
&& a.protocol === b.protocol
|
|
311
|
-
&& a.port === b.port
|
|
312
344
|
&& a.hash === b.hash
|
|
313
|
-
&& a.
|
|
314
|
-
|
|
345
|
+
&& areSearchParamsEqual(a.searchParams, b.searchParams));
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Whether the search params passed are equal in value.
|
|
349
|
+
*
|
|
350
|
+
* @note
|
|
351
|
+
* Order is not significant, matching how the other unordered collections in the library are
|
|
352
|
+
* compared. Repeated keys are, so this is a comparison of multisets rather than of sets:
|
|
353
|
+
* `a=1&a=2` is equal to `a=2&a=1`, but not to `a=1&a=1`.
|
|
354
|
+
*/
|
|
355
|
+
function areSearchParamsEqual(a, b) {
|
|
356
|
+
const serializedA = a.toString();
|
|
357
|
+
const serializedB = b.toString();
|
|
358
|
+
// Identical serializations are equal under any ordering, and this is by far the common case, so
|
|
359
|
+
// it is worth checking before sorting anything.
|
|
360
|
+
return serializedA === serializedB || sortSearchParams(serializedA) === sortSearchParams(serializedB);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Reorder a serialized query string so that params holding the same pairs compare as equal
|
|
364
|
+
* regardless of the order they appear in.
|
|
365
|
+
*
|
|
366
|
+
* @note
|
|
367
|
+
* The serializer percent-encodes `&` and `=` wherever they appear inside a name or a value, so
|
|
368
|
+
* splitting on `&` recovers exactly the pairs and nothing else.
|
|
369
|
+
*/
|
|
370
|
+
function sortSearchParams(serialized) {
|
|
371
|
+
return serialized.split('&').sort().join('&');
|
|
315
372
|
}
|
|
316
373
|
function isPropertyEqual(a, b, state, property) {
|
|
317
374
|
if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE)
|
|
@@ -321,7 +378,6 @@ function isPropertyEqual(a, b, state, property) {
|
|
|
321
378
|
return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
|
|
322
379
|
}
|
|
323
380
|
|
|
324
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
325
381
|
const toString = Object.prototype.toString;
|
|
326
382
|
/**
|
|
327
383
|
* Create a comparator method based on the type-specific equality comparators passed.
|
|
@@ -360,7 +416,7 @@ function createEqualityComparator(config) {
|
|
|
360
416
|
// Checks are listed in order of commonality of use-case:
|
|
361
417
|
// 1. Common complex object types (plain object, array)
|
|
362
418
|
// 2. Common data values (date, regexp)
|
|
363
|
-
// 3. Less-common complex object types (map, set)
|
|
419
|
+
// 3. Less-common complex object types (map, set, null-prototype object)
|
|
364
420
|
// 4. Less-common data values (promise, primitive wrappers)
|
|
365
421
|
// Inherently this is both subjective and assumptive, however
|
|
366
422
|
// when reviewing comparable libraries in the wild this order
|
|
@@ -393,6 +449,10 @@ function createEqualityComparator(config) {
|
|
|
393
449
|
if (constructor === Set) {
|
|
394
450
|
return areSetsEqual(a, b, state);
|
|
395
451
|
}
|
|
452
|
+
if (constructor == null) {
|
|
453
|
+
// Objects with a prototype of `null` are plain objects.
|
|
454
|
+
return areObjectsEqual(a, b, state);
|
|
455
|
+
}
|
|
396
456
|
if (constructor === Promise) {
|
|
397
457
|
// Avoid tag checks for promise values, since we know if they are not referentially equal
|
|
398
458
|
// then they are not equal.
|
|
@@ -434,7 +494,13 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict,
|
|
|
434
494
|
areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
|
|
435
495
|
areDataViewsEqual,
|
|
436
496
|
areDatesEqual: areDatesEqual,
|
|
437
|
-
|
|
497
|
+
// `Error` subclasses routinely carry their own enumerable properties (`status`, `code`, ...),
|
|
498
|
+
// which the error comparator alone does not see, so it is composed with the object comparator.
|
|
499
|
+
// `name` / `message` / `stack` are own but not enumerable, which is why errors need a
|
|
500
|
+
// comparator of their own rather than being treated as plain objects in the first place.
|
|
501
|
+
areErrorsEqual: strict
|
|
502
|
+
? combineComparators(areErrorsEqual, areObjectsEqualStrict)
|
|
503
|
+
: combineComparators(areErrorsEqual, areObjectsEqual),
|
|
438
504
|
areFunctionsEqual: strictEqual,
|
|
439
505
|
areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
|
|
440
506
|
areNumbersEqual: sameValueEqual,
|
|
@@ -453,11 +519,15 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict,
|
|
|
453
519
|
}
|
|
454
520
|
if (circular) {
|
|
455
521
|
const areArraysEqual = createIsCircular(config.areArraysEqual);
|
|
522
|
+
// Errors are included because comparing `cause` and own properties by value means an error
|
|
523
|
+
// that references itself would otherwise recurse without bound.
|
|
524
|
+
const areErrorsEqual = createIsCircular(config.areErrorsEqual);
|
|
456
525
|
const areMapsEqual = createIsCircular(config.areMapsEqual);
|
|
457
526
|
const areObjectsEqual = createIsCircular(config.areObjectsEqual);
|
|
458
527
|
const areSetsEqual = createIsCircular(config.areSetsEqual);
|
|
459
528
|
config = Object.assign({}, config, {
|
|
460
529
|
areArraysEqual,
|
|
530
|
+
areErrorsEqual,
|
|
461
531
|
areMapsEqual,
|
|
462
532
|
areObjectsEqual,
|
|
463
533
|
areSetsEqual,
|
|
@@ -512,13 +582,13 @@ function createIsEqual({ circular, comparator, createState, equals, strict }) {
|
|
|
512
582
|
/**
|
|
513
583
|
* Create a map of `toString()` values to their respective handlers for `tag`-based lookups.
|
|
514
584
|
*/
|
|
515
|
-
function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual,
|
|
585
|
+
function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, }) {
|
|
516
586
|
return {
|
|
517
587
|
'[object Arguments]': areObjectsEqual,
|
|
518
588
|
'[object Array]': areArraysEqual,
|
|
519
589
|
'[object ArrayBuffer]': areArrayBuffersEqual,
|
|
520
590
|
'[object AsyncGeneratorFunction]': areFunctionsEqual,
|
|
521
|
-
'[object BigInt]':
|
|
591
|
+
'[object BigInt]': arePrimitiveWrappersEqual,
|
|
522
592
|
'[object BigInt64Array]': areTypedArraysEqual,
|
|
523
593
|
'[object BigUint64Array]': areTypedArraysEqual,
|
|
524
594
|
'[object Boolean]': arePrimitiveWrappersEqual,
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
3
2
|
const { hasOwnProperty } = Object.prototype;
|
|
4
3
|
/**
|
|
5
4
|
* Combine two comparators into a single comparators.
|
|
@@ -53,6 +52,9 @@ Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property));
|
|
|
53
52
|
const PREACT_VNODE = '__v';
|
|
54
53
|
const PREACT_OWNER = '__o';
|
|
55
54
|
const REACT_OWNER = '_owner';
|
|
55
|
+
// `Float16Array` is recent enough that it cannot be referenced unguarded, and capturing its
|
|
56
|
+
// availability once keeps that detail out of the comparison itself.
|
|
57
|
+
const HAS_FLOAT_16_ARRAY = typeof Float16Array !== 'undefined';
|
|
56
58
|
const { getOwnPropertyDescriptor, keys } = Object;
|
|
57
59
|
/**
|
|
58
60
|
* Whether the values passed are equal based on a [SameValue](https://262.ecma-international.org/7.0/#sec-samevalue) basis.
|
|
@@ -124,9 +126,19 @@ function areDatesEqual(a, b) {
|
|
|
124
126
|
}
|
|
125
127
|
/**
|
|
126
128
|
* Whether the errors passed are equal in value.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
*
|
|
130
|
+
* @note
|
|
131
|
+
* `name`, `message` and `stack` are own properties but are not enumerable, so they are compared
|
|
132
|
+
* explicitly. `cause` is compared by value rather than by reference, matching how every other
|
|
133
|
+
* nested value in the comparison is treated. Own enumerable properties (which custom `Error`
|
|
134
|
+
* subclasses commonly add) are compared by composing this with the object comparator in the
|
|
135
|
+
* comparator config, so that the strict and circular variants apply to them as well.
|
|
136
|
+
*/
|
|
137
|
+
function areErrorsEqual(a, b, state) {
|
|
138
|
+
return (a.name === b.name
|
|
139
|
+
&& a.message === b.message
|
|
140
|
+
&& a.stack === b.stack
|
|
141
|
+
&& state.equals(a.cause, b.cause, 'cause', 'cause', a, b, state));
|
|
130
142
|
}
|
|
131
143
|
/**
|
|
132
144
|
* Whether the `Map`s are equal in value.
|
|
@@ -292,6 +304,19 @@ function areTypedArraysEqual(a, b) {
|
|
|
292
304
|
if (b.length !== index || a.byteOffset !== b.byteOffset) {
|
|
293
305
|
return false;
|
|
294
306
|
}
|
|
307
|
+
// Only float-backed views can hold `NaN`, and the additional check needed to treat it as equal
|
|
308
|
+
// to itself measurably slows the loop, so integer views keep the plain comparison. This is
|
|
309
|
+
// hoisted out of the loop so the cost is paid once per call rather than once per element.
|
|
310
|
+
if (a instanceof Float64Array || a instanceof Float32Array || (HAS_FLOAT_16_ARRAY && a instanceof Float16Array)) {
|
|
311
|
+
while (index-- > 0) {
|
|
312
|
+
// `NaN` is the only value not equal to itself, and it is treated as equal here to match
|
|
313
|
+
// the SameValueZero semantics used for every other numeric comparison in the library.
|
|
314
|
+
if (a[index] !== b[index] && (a[index] === a[index] || b[index] === b[index])) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
295
320
|
while (index-- > 0) {
|
|
296
321
|
if (a[index] !== b[index]) {
|
|
297
322
|
return false;
|
|
@@ -303,13 +328,45 @@ function areTypedArraysEqual(a, b) {
|
|
|
303
328
|
* Whether the URL instances are equal in value.
|
|
304
329
|
*/
|
|
305
330
|
function areUrlsEqual(a, b) {
|
|
306
|
-
|
|
331
|
+
// `href` is the normalized serialization of every component, so matching hrefs are equal without
|
|
332
|
+
// any further work. Only a difference in query parameter ordering can survive a mismatch here.
|
|
333
|
+
if (a.href === b.href) {
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
return (a.protocol === b.protocol
|
|
337
|
+
&& a.username === b.username
|
|
338
|
+
&& a.password === b.password
|
|
339
|
+
// `host` covers both the hostname and the port.
|
|
340
|
+
&& a.host === b.host
|
|
307
341
|
&& a.pathname === b.pathname
|
|
308
|
-
&& a.protocol === b.protocol
|
|
309
|
-
&& a.port === b.port
|
|
310
342
|
&& a.hash === b.hash
|
|
311
|
-
&& a.
|
|
312
|
-
|
|
343
|
+
&& areSearchParamsEqual(a.searchParams, b.searchParams));
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Whether the search params passed are equal in value.
|
|
347
|
+
*
|
|
348
|
+
* @note
|
|
349
|
+
* Order is not significant, matching how the other unordered collections in the library are
|
|
350
|
+
* compared. Repeated keys are, so this is a comparison of multisets rather than of sets:
|
|
351
|
+
* `a=1&a=2` is equal to `a=2&a=1`, but not to `a=1&a=1`.
|
|
352
|
+
*/
|
|
353
|
+
function areSearchParamsEqual(a, b) {
|
|
354
|
+
const serializedA = a.toString();
|
|
355
|
+
const serializedB = b.toString();
|
|
356
|
+
// Identical serializations are equal under any ordering, and this is by far the common case, so
|
|
357
|
+
// it is worth checking before sorting anything.
|
|
358
|
+
return serializedA === serializedB || sortSearchParams(serializedA) === sortSearchParams(serializedB);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Reorder a serialized query string so that params holding the same pairs compare as equal
|
|
362
|
+
* regardless of the order they appear in.
|
|
363
|
+
*
|
|
364
|
+
* @note
|
|
365
|
+
* The serializer percent-encodes `&` and `=` wherever they appear inside a name or a value, so
|
|
366
|
+
* splitting on `&` recovers exactly the pairs and nothing else.
|
|
367
|
+
*/
|
|
368
|
+
function sortSearchParams(serialized) {
|
|
369
|
+
return serialized.split('&').sort().join('&');
|
|
313
370
|
}
|
|
314
371
|
function isPropertyEqual(a, b, state, property) {
|
|
315
372
|
if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE)
|
|
@@ -319,7 +376,6 @@ function isPropertyEqual(a, b, state, property) {
|
|
|
319
376
|
return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
|
|
320
377
|
}
|
|
321
378
|
|
|
322
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
323
379
|
const toString = Object.prototype.toString;
|
|
324
380
|
/**
|
|
325
381
|
* Create a comparator method based on the type-specific equality comparators passed.
|
|
@@ -358,7 +414,7 @@ function createEqualityComparator(config) {
|
|
|
358
414
|
// Checks are listed in order of commonality of use-case:
|
|
359
415
|
// 1. Common complex object types (plain object, array)
|
|
360
416
|
// 2. Common data values (date, regexp)
|
|
361
|
-
// 3. Less-common complex object types (map, set)
|
|
417
|
+
// 3. Less-common complex object types (map, set, null-prototype object)
|
|
362
418
|
// 4. Less-common data values (promise, primitive wrappers)
|
|
363
419
|
// Inherently this is both subjective and assumptive, however
|
|
364
420
|
// when reviewing comparable libraries in the wild this order
|
|
@@ -391,6 +447,10 @@ function createEqualityComparator(config) {
|
|
|
391
447
|
if (constructor === Set) {
|
|
392
448
|
return areSetsEqual(a, b, state);
|
|
393
449
|
}
|
|
450
|
+
if (constructor == null) {
|
|
451
|
+
// Objects with a prototype of `null` are plain objects.
|
|
452
|
+
return areObjectsEqual(a, b, state);
|
|
453
|
+
}
|
|
394
454
|
if (constructor === Promise) {
|
|
395
455
|
// Avoid tag checks for promise values, since we know if they are not referentially equal
|
|
396
456
|
// then they are not equal.
|
|
@@ -432,7 +492,13 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict,
|
|
|
432
492
|
areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
|
|
433
493
|
areDataViewsEqual,
|
|
434
494
|
areDatesEqual: areDatesEqual,
|
|
435
|
-
|
|
495
|
+
// `Error` subclasses routinely carry their own enumerable properties (`status`, `code`, ...),
|
|
496
|
+
// which the error comparator alone does not see, so it is composed with the object comparator.
|
|
497
|
+
// `name` / `message` / `stack` are own but not enumerable, which is why errors need a
|
|
498
|
+
// comparator of their own rather than being treated as plain objects in the first place.
|
|
499
|
+
areErrorsEqual: strict
|
|
500
|
+
? combineComparators(areErrorsEqual, areObjectsEqualStrict)
|
|
501
|
+
: combineComparators(areErrorsEqual, areObjectsEqual),
|
|
436
502
|
areFunctionsEqual: strictEqual,
|
|
437
503
|
areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
|
|
438
504
|
areNumbersEqual: sameValueEqual,
|
|
@@ -451,11 +517,15 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict,
|
|
|
451
517
|
}
|
|
452
518
|
if (circular) {
|
|
453
519
|
const areArraysEqual = createIsCircular(config.areArraysEqual);
|
|
520
|
+
// Errors are included because comparing `cause` and own properties by value means an error
|
|
521
|
+
// that references itself would otherwise recurse without bound.
|
|
522
|
+
const areErrorsEqual = createIsCircular(config.areErrorsEqual);
|
|
454
523
|
const areMapsEqual = createIsCircular(config.areMapsEqual);
|
|
455
524
|
const areObjectsEqual = createIsCircular(config.areObjectsEqual);
|
|
456
525
|
const areSetsEqual = createIsCircular(config.areSetsEqual);
|
|
457
526
|
config = Object.assign({}, config, {
|
|
458
527
|
areArraysEqual,
|
|
528
|
+
areErrorsEqual,
|
|
459
529
|
areMapsEqual,
|
|
460
530
|
areObjectsEqual,
|
|
461
531
|
areSetsEqual,
|
|
@@ -510,13 +580,13 @@ function createIsEqual({ circular, comparator, createState, equals, strict }) {
|
|
|
510
580
|
/**
|
|
511
581
|
* Create a map of `toString()` values to their respective handlers for `tag`-based lookups.
|
|
512
582
|
*/
|
|
513
|
-
function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual,
|
|
583
|
+
function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, }) {
|
|
514
584
|
return {
|
|
515
585
|
'[object Arguments]': areObjectsEqual,
|
|
516
586
|
'[object Array]': areArraysEqual,
|
|
517
587
|
'[object ArrayBuffer]': areArrayBuffersEqual,
|
|
518
588
|
'[object AsyncGeneratorFunction]': areFunctionsEqual,
|
|
519
|
-
'[object BigInt]':
|
|
589
|
+
'[object BigInt]': arePrimitiveWrappersEqual,
|
|
520
590
|
'[object BigInt64Array]': areTypedArraysEqual,
|
|
521
591
|
'[object BigUint64Array]': areTypedArraysEqual,
|
|
522
592
|
'[object Boolean]': arePrimitiveWrappersEqual,
|
package/package.json
CHANGED
|
@@ -9,41 +9,41 @@
|
|
|
9
9
|
},
|
|
10
10
|
"description": "A blazing-fast equality comparison utility for a variety of use-cases",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@planttheidea/build-tools": "^2.0.
|
|
13
|
-
"@types/lodash": "^4.17.
|
|
12
|
+
"@planttheidea/build-tools": "^2.0.8",
|
|
13
|
+
"@types/lodash": "^4.17.25",
|
|
14
14
|
"@types/node": "^24.13.3",
|
|
15
15
|
"@types/ramda": "^0.32.0",
|
|
16
|
-
"@types/react": "^19.2.
|
|
17
|
-
"@types/react-dom": "^19.2.
|
|
18
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
19
|
-
"@typescript-eslint/parser": "^8.
|
|
20
|
-
"@vitest/coverage-v8": "^4.1.
|
|
16
|
+
"@types/react": "^19.2.18",
|
|
17
|
+
"@types/react-dom": "^19.2.5",
|
|
18
|
+
"@typescript-eslint/eslint-plugin": "^8.69.0",
|
|
19
|
+
"@typescript-eslint/parser": "^8.69.0",
|
|
20
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
21
21
|
"cli-table3": "^0.6.5",
|
|
22
22
|
"decircularize": "^1.0.0",
|
|
23
23
|
"deep-eql": "^5.0.2",
|
|
24
24
|
"deep-equal": "^2.2.3",
|
|
25
25
|
"dequal": "^2.0.3",
|
|
26
|
-
"es-toolkit": "^1.
|
|
27
|
-
"eslint": "^9.39.
|
|
26
|
+
"es-toolkit": "^1.52.0",
|
|
27
|
+
"eslint": "^9.39.5",
|
|
28
28
|
"eslint-friendly-formatter": "^4.0.1",
|
|
29
29
|
"eslint-plugin-import": "^2.32.0",
|
|
30
30
|
"fast-deep-equal": "^3.1.3",
|
|
31
31
|
"fast-glob": "^3.3.3",
|
|
32
32
|
"lodash": "^4.18.1",
|
|
33
33
|
"nano-equal": "^2.0.2",
|
|
34
|
-
"prettier": "^3.9.
|
|
35
|
-
"react": "^19.2.
|
|
36
|
-
"react-dom": "^19.2.
|
|
34
|
+
"prettier": "^3.9.6",
|
|
35
|
+
"react": "^19.2.8",
|
|
36
|
+
"react-dom": "^19.2.8",
|
|
37
37
|
"react-fast-compare": "^3.2.2",
|
|
38
|
-
"release-it": "^
|
|
39
|
-
"rollup": "^4.
|
|
38
|
+
"release-it": "^21.0.2",
|
|
39
|
+
"rollup": "^4.63.1",
|
|
40
40
|
"shallow-equal-fuzzy": "^0.0.2",
|
|
41
|
-
"tinybench": "^6.
|
|
42
|
-
"typescript": "^
|
|
43
|
-
"typescript-eslint": "^8.
|
|
41
|
+
"tinybench": "^6.1.4",
|
|
42
|
+
"typescript": "^6.0.3",
|
|
43
|
+
"typescript-eslint": "^8.69.0",
|
|
44
44
|
"underscore": "^1.13.8",
|
|
45
|
-
"vite": "^8.
|
|
46
|
-
"vitest": "^4.1.
|
|
45
|
+
"vite": "^8.2.2",
|
|
46
|
+
"vitest": "^4.1.11"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=6.0.0"
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"sideEffects": false,
|
|
111
111
|
"type": "module",
|
|
112
112
|
"types": "./index.d.ts",
|
|
113
|
-
"version": "6.0.
|
|
113
|
+
"version": "6.0.4"
|
|
114
114
|
}
|