fast-equals 6.3.0 → 6.4.0

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 CHANGED
@@ -13,7 +13,7 @@ The following types are handled out-of-the-box:
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
16
+ - `URL` / `URLSearchParams` objects
17
17
  - Primitive wrappers (`new Boolean()` / `new Number()` / `new String()`, and boxed `BigInt`)
18
18
  - Custom class instances, including subclasses of native classes
19
19
 
@@ -235,8 +235,8 @@ Performs the same comparison as `deepEqual` but performs a strict comparison of
235
235
  - Checking full descriptor of properties on the object to match
236
236
  - Checking non-index properties on arrays
237
237
  - Checking non-key properties on `Map` / `Set` objects
238
- - Checking own properties on objects that hold their value internally (`Date`, `RegExp`, `URL`, primitive wrappers,
239
- `ArrayBuffer`, `DataView` and `TypedArray` objects), including `lastIndex` on `RegExp` objects
238
+ - Checking own properties on objects that hold their value internally (`Date`, `RegExp`, `URL`, `URLSearchParams`,
239
+ primitive wrappers, `ArrayBuffer`, `DataView` and `TypedArray` objects), including `lastIndex` on `RegExp` objects
240
240
 
241
241
  ```ts
242
242
  const array = [{ foo: 'bar' }];
@@ -267,8 +267,8 @@ Performs the same comparison as `shallowEqual` but performs a strict comparison
267
267
  - Checking full descriptor of properties on the object to match
268
268
  - Checking non-index properties on arrays
269
269
  - Checking non-key properties on `Map` / `Set` objects
270
- - Checking own properties on objects that hold their value internally (`Date`, `RegExp`, `URL`, primitive wrappers,
271
- `ArrayBuffer`, `DataView` and `TypedArray` objects), including `lastIndex` on `RegExp` objects
270
+ - Checking own properties on objects that hold their value internally (`Date`, `RegExp`, `URL`, `URLSearchParams`,
271
+ primitive wrappers, `ArrayBuffer`, `DataView` and `TypedArray` objects), including `lastIndex` on `RegExp` objects
272
272
 
273
273
  ```ts
274
274
  const array = ['foo'];
@@ -290,8 +290,8 @@ Performs the same comparison as `circularDeepEqual` but performs a strict compar
290
290
  - Checking full descriptor of properties on the object to match
291
291
  - Checking non-index properties on arrays
292
292
  - Checking non-key properties on `Map` / `Set` objects
293
- - Checking own properties on objects that hold their value internally (`Date`, `RegExp`, `URL`, primitive wrappers,
294
- `ArrayBuffer`, `DataView` and `TypedArray` objects), including `lastIndex` on `RegExp` objects
293
+ - Checking own properties on objects that hold their value internally (`Date`, `RegExp`, `URL`, `URLSearchParams`,
294
+ primitive wrappers, `ArrayBuffer`, `DataView` and `TypedArray` objects), including `lastIndex` on `RegExp` objects
295
295
 
296
296
  ```ts
297
297
  function Circular(value) {
@@ -331,8 +331,8 @@ Performs the same comparison as `circularShallowEqual` but performs a strict com
331
331
  - Checking full descriptor of properties on the object to match
332
332
  - Checking non-index properties on arrays
333
333
  - Checking non-key properties on `Map` / `Set` objects
334
- - Checking own properties on objects that hold their value internally (`Date`, `RegExp`, `URL`, primitive wrappers,
335
- `ArrayBuffer`, `DataView` and `TypedArray` objects), including `lastIndex` on `RegExp` objects
334
+ - Checking own properties on objects that hold their value internally (`Date`, `RegExp`, `URL`, `URLSearchParams`,
335
+ primitive wrappers, `ArrayBuffer`, `DataView` and `TypedArray` objects), including `lastIndex` on `RegExp` objects
336
336
 
337
337
  ```ts
338
338
  const array = ['foo'];
@@ -377,6 +377,7 @@ interface ComparatorConfig<Meta> {
377
377
  areRegExpsEqual: EqualityComparator<Meta>;
378
378
  areSetsEqual: EqualityComparator<Meta>;
379
379
  areTypedArraysEqual: EqualityComparator<Meta>;
380
+ areUrlSearchParamsEqual: EqualityComparator<Meta>;
380
381
  areUrlsEqual: EqualityComparator<Meta>;
381
382
  getUnsupportedCustomComparator:
382
383
  (<Type>(a: Type, b: Type, state: State<Meta>, tag: string) => EqualityComparator<Meta> | undefined) | undefined;
@@ -492,13 +492,19 @@ function areRegExpsEqualStrict(a, b, state) {
492
492
  * compared. Repeated keys are, so this is a comparison of multisets rather than of sets:
493
493
  * `a=1&a=2` is equal to `a=2&a=1`, but not to `a=1&a=1`.
494
494
  */
495
- function areSearchParamsEqual(a, b) {
495
+ function areUrlSearchParamsEqual(a, b) {
496
496
  const serializedA = a.toString();
497
497
  const serializedB = b.toString();
498
498
  // Identical serializations are equal under any ordering, and this is by far the common case, so
499
499
  // it is worth checking before sorting anything.
500
500
  return serializedA === serializedB || sortSearchParams(serializedA) === sortSearchParams(serializedB);
501
501
  }
502
+ /**
503
+ * Whether the search params passed are equal in value with strict property checking.
504
+ */
505
+ function areUrlSearchParamsEqualStrict(a, b, state) {
506
+ return areUrlSearchParamsEqual(a, b) && areOwnPropertiesEqualStrict(a, b, state, 0, 0);
507
+ }
502
508
  /**
503
509
  * Whether the `Set`s are equal in value.
504
510
  */
@@ -609,7 +615,7 @@ function areUrlsEqual(a, b) {
609
615
  && a.host === b.host
610
616
  && a.pathname === b.pathname
611
617
  && a.hash === b.hash
612
- && areSearchParamsEqual(a.searchParams, b.searchParams));
618
+ && areUrlSearchParamsEqual(a.searchParams, b.searchParams));
613
619
  }
614
620
  /**
615
621
  * Whether the URL instances are equal in value with strict property checking.
@@ -763,6 +769,7 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict,
763
769
  areRegExpsEqual: strict ? areRegExpsEqualStrict : areRegExpsEqual,
764
770
  areSetsEqual: strict ? areSetsEqualStrict : areSetsEqual,
765
771
  areTypedArraysEqual: strict ? areTypedArraysEqualStrict : areTypedArraysEqual,
772
+ areUrlSearchParamsEqual: strict ? areUrlSearchParamsEqualStrict : areUrlSearchParamsEqual,
766
773
  areUrlsEqual: strict ? areUrlsEqualStrict : areUrlsEqual,
767
774
  getUnsupportedCustomComparator: undefined,
768
775
  strictNullPrototypeComparison,
@@ -832,7 +839,7 @@ function createIsEqual({ circular, comparator, createState, equals, strict }) {
832
839
  /**
833
840
  * Create a map of `toString()` values to their respective handlers for `tag`-based lookups.
834
841
  */
835
- function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, }) {
842
+ function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlSearchParamsEqual, areUrlsEqual, }) {
836
843
  return {
837
844
  '[object Arguments]': areObjectsEqual,
838
845
  '[object Array]': areArraysEqual,
@@ -868,6 +875,7 @@ function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, ar
868
875
  '[object Set]': areSetsEqual,
869
876
  '[object String]': arePrimitiveWrappersEqual,
870
877
  '[object URL]': areUrlsEqual,
878
+ '[object URLSearchParams]': areUrlSearchParamsEqual,
871
879
  '[object Uint8Array]': areTypedArraysEqual,
872
880
  '[object Uint8ClampedArray]': areTypedArraysEqual,
873
881
  '[object Uint16Array]': areTypedArraysEqual,
@@ -90,6 +90,11 @@ interface ComparatorConfig<Meta> {
90
90
  * additional properties added to the typed array.
91
91
  */
92
92
  areTypedArraysEqual: EqualityComparator<Meta>;
93
+ /**
94
+ * Whether the `URLSearchParams` passed are equal in value. In strict mode, this includes
95
+ * additional properties added to the `URLSearchParams`.
96
+ */
97
+ areUrlSearchParamsEqual: EqualityComparator<Meta>;
93
98
  /**
94
99
  * Whether the URLs passed are equal in value. In strict mode, this includes
95
100
  * additional properties added to the URL.
@@ -90,6 +90,11 @@ interface ComparatorConfig<Meta> {
90
90
  * additional properties added to the typed array.
91
91
  */
92
92
  areTypedArraysEqual: EqualityComparator<Meta>;
93
+ /**
94
+ * Whether the `URLSearchParams` passed are equal in value. In strict mode, this includes
95
+ * additional properties added to the `URLSearchParams`.
96
+ */
97
+ areUrlSearchParamsEqual: EqualityComparator<Meta>;
93
98
  /**
94
99
  * Whether the URLs passed are equal in value. In strict mode, this includes
95
100
  * additional properties added to the URL.
package/dist/es/index.mjs CHANGED
@@ -490,13 +490,19 @@ function areRegExpsEqualStrict(a, b, state) {
490
490
  * compared. Repeated keys are, so this is a comparison of multisets rather than of sets:
491
491
  * `a=1&a=2` is equal to `a=2&a=1`, but not to `a=1&a=1`.
492
492
  */
493
- function areSearchParamsEqual(a, b) {
493
+ function areUrlSearchParamsEqual(a, b) {
494
494
  const serializedA = a.toString();
495
495
  const serializedB = b.toString();
496
496
  // Identical serializations are equal under any ordering, and this is by far the common case, so
497
497
  // it is worth checking before sorting anything.
498
498
  return serializedA === serializedB || sortSearchParams(serializedA) === sortSearchParams(serializedB);
499
499
  }
500
+ /**
501
+ * Whether the search params passed are equal in value with strict property checking.
502
+ */
503
+ function areUrlSearchParamsEqualStrict(a, b, state) {
504
+ return areUrlSearchParamsEqual(a, b) && areOwnPropertiesEqualStrict(a, b, state, 0, 0);
505
+ }
500
506
  /**
501
507
  * Whether the `Set`s are equal in value.
502
508
  */
@@ -607,7 +613,7 @@ function areUrlsEqual(a, b) {
607
613
  && a.host === b.host
608
614
  && a.pathname === b.pathname
609
615
  && a.hash === b.hash
610
- && areSearchParamsEqual(a.searchParams, b.searchParams));
616
+ && areUrlSearchParamsEqual(a.searchParams, b.searchParams));
611
617
  }
612
618
  /**
613
619
  * Whether the URL instances are equal in value with strict property checking.
@@ -761,6 +767,7 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict,
761
767
  areRegExpsEqual: strict ? areRegExpsEqualStrict : areRegExpsEqual,
762
768
  areSetsEqual: strict ? areSetsEqualStrict : areSetsEqual,
763
769
  areTypedArraysEqual: strict ? areTypedArraysEqualStrict : areTypedArraysEqual,
770
+ areUrlSearchParamsEqual: strict ? areUrlSearchParamsEqualStrict : areUrlSearchParamsEqual,
764
771
  areUrlsEqual: strict ? areUrlsEqualStrict : areUrlsEqual,
765
772
  getUnsupportedCustomComparator: undefined,
766
773
  strictNullPrototypeComparison,
@@ -830,7 +837,7 @@ function createIsEqual({ circular, comparator, createState, equals, strict }) {
830
837
  /**
831
838
  * Create a map of `toString()` values to their respective handlers for `tag`-based lookups.
832
839
  */
833
- function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, }) {
840
+ function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlSearchParamsEqual, areUrlsEqual, }) {
834
841
  return {
835
842
  '[object Arguments]': areObjectsEqual,
836
843
  '[object Array]': areArraysEqual,
@@ -866,6 +873,7 @@ function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, ar
866
873
  '[object Set]': areSetsEqual,
867
874
  '[object String]': arePrimitiveWrappersEqual,
868
875
  '[object URL]': areUrlsEqual,
876
+ '[object URLSearchParams]': areUrlSearchParamsEqual,
869
877
  '[object Uint8Array]': areTypedArraysEqual,
870
878
  '[object Uint8ClampedArray]': areTypedArraysEqual,
871
879
  '[object Uint16Array]': areTypedArraysEqual,
package/index.d.ts CHANGED
@@ -90,6 +90,11 @@ interface ComparatorConfig<Meta> {
90
90
  * additional properties added to the typed array.
91
91
  */
92
92
  areTypedArraysEqual: EqualityComparator<Meta>;
93
+ /**
94
+ * Whether the `URLSearchParams` passed are equal in value. In strict mode, this includes
95
+ * additional properties added to the `URLSearchParams`.
96
+ */
97
+ areUrlSearchParamsEqual: EqualityComparator<Meta>;
93
98
  /**
94
99
  * Whether the URLs passed are equal in value. In strict mode, this includes
95
100
  * additional properties added to the URL.
package/package.json CHANGED
@@ -110,5 +110,5 @@
110
110
  "sideEffects": false,
111
111
  "type": "module",
112
112
  "types": "./index.d.ts",
113
- "version": "6.3.0"
113
+ "version": "6.4.0"
114
114
  }