fast-equals 5.3.4 → 5.4.1

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.
@@ -1,58 +1,202 @@
1
- import type { CustomEqualCreatorOptions } from './internalTypes.d.cts';
2
- import type { sameValueZeroEqual } from './utils.d.cts';
3
- export { sameValueZeroEqual };
4
- export type {
5
- AnyEqualityComparator,
6
- Cache,
7
- CircularState,
8
- ComparatorConfig,
9
- CreateCustomComparatorConfig,
10
- CreateState,
11
- CustomEqualCreatorOptions,
12
- DefaultState,
13
- Dictionary,
14
- EqualityComparator,
15
- EqualityComparatorCreator,
16
- InternalEqualityComparator,
17
- PrimitiveWrapper,
18
- State,
19
- TypeEqualityComparator,
20
- TypedArray,
21
- } from './internalTypes.d.cts';
1
+ /**
2
+ * Cache used to store references to objects, used for circular
3
+ * reference checks.
4
+ */
5
+ interface Cache<Key extends object, Value> {
6
+ delete(key: Key): boolean;
7
+ get(key: Key): Value | undefined;
8
+ set(key: Key, value: any): any;
9
+ }
10
+ interface State<Meta> {
11
+ /**
12
+ * Cache used to identify circular references
13
+ */
14
+ readonly cache: Cache<any, any> | undefined;
15
+ /**
16
+ * Method used to determine equality of nested value.
17
+ */
18
+ readonly equals: InternalEqualityComparator<Meta>;
19
+ /**
20
+ * Additional value that can be used for comparisons.
21
+ */
22
+ meta: Meta;
23
+ /**
24
+ * Whether the equality comparison is strict, meaning it matches
25
+ * all properties (including symbols and non-enumerable properties)
26
+ * with equal shape of descriptors.
27
+ */
28
+ readonly strict: boolean;
29
+ }
30
+ interface CircularState<Meta> extends State<Meta> {
31
+ readonly cache: Cache<any, any>;
32
+ }
33
+ interface DefaultState<Meta> extends State<Meta> {
34
+ readonly cache: undefined;
35
+ }
36
+ interface Dictionary<Value = any> {
37
+ [key: string | symbol]: Value;
38
+ $$typeof?: any;
39
+ }
40
+ interface ComparatorConfig<Meta> {
41
+ /**
42
+ * Whether the array buffers passed are equal in value. In strict mode, this includes
43
+ * additional properties added to the array.
44
+ */
45
+ areArrayBuffersEqual: TypeEqualityComparator<any, Meta>;
46
+ /**
47
+ * Whether the arrays passed are equal in value. In strict mode, this includes
48
+ * additional properties added to the array.
49
+ */
50
+ areArraysEqual: TypeEqualityComparator<any, Meta>;
51
+ /**
52
+ * Whether the data views passed are equal in value.
53
+ */
54
+ areDataViewsEqual: TypeEqualityComparator<any, Meta>;
55
+ /**
56
+ * Whether the dates passed are equal in value.
57
+ */
58
+ areDatesEqual: TypeEqualityComparator<any, Meta>;
59
+ /**
60
+ * Whether the errors passed are equal in value.
61
+ */
62
+ areErrorsEqual: TypeEqualityComparator<any, Meta>;
63
+ /**
64
+ * Whether the functions passed are equal in value.
65
+ */
66
+ areFunctionsEqual: TypeEqualityComparator<any, Meta>;
67
+ /**
68
+ * Whether the maps passed are equal in value. In strict mode, this includes
69
+ * additional properties added to the map.
70
+ */
71
+ areMapsEqual: TypeEqualityComparator<any, Meta>;
72
+ /**
73
+ * Whether the numbers passed are equal in value.
74
+ */
75
+ areNumbersEqual: TypeEqualityComparator<any, Meta>;
76
+ /**
77
+ * Whether the objects passed are equal in value. In strict mode, this includes
78
+ * non-enumerable properties added to the map, as well as symbol properties.
79
+ */
80
+ areObjectsEqual: TypeEqualityComparator<any, Meta>;
81
+ /**
82
+ * Whether the primitive wrappers passed are equal in value.
83
+ */
84
+ arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
85
+ /**
86
+ * Whether the regexps passed are equal in value.
87
+ */
88
+ areRegExpsEqual: TypeEqualityComparator<any, Meta>;
89
+ /**
90
+ * Whether the sets passed are equal in value. In strict mode, this includes
91
+ * additional properties added to the set.
92
+ */
93
+ areSetsEqual: TypeEqualityComparator<any, Meta>;
94
+ /**
95
+ * Whether the typed arrays passed are equal in value. In strict mode, this includes
96
+ * additional properties added to the typed array.
97
+ */
98
+ areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
99
+ /**
100
+ * Whether the URLs passed are equal in value.
101
+ */
102
+ areUrlsEqual: TypeEqualityComparator<any, Meta>;
103
+ /**
104
+ * Whether two values with unknown `@@toStringTag` are equal in value. This comparator is
105
+ * called when no other comparator applies.
106
+ *
107
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag
108
+ */
109
+ unknownTagComparators: Record<string, TypeEqualityComparator<any, Meta>> | undefined;
110
+ }
111
+ type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
112
+ type CreateState<Meta> = () => {
113
+ cache?: Cache<any, any> | undefined;
114
+ meta?: Meta;
115
+ };
116
+ type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) => boolean;
117
+ type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
118
+ type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
119
+ type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
120
+ type PrimitiveWrapper = Boolean | Number | String;
121
+ /**
122
+ * Type which encompasses possible instances of TypedArray
123
+ * classes.
124
+ */
125
+ type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
126
+ type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
127
+ interface CustomEqualCreatorOptions<Meta> {
128
+ /**
129
+ * Whether circular references should be supported. It causes the
130
+ * comparison to be slower, but for objects that have circular references
131
+ * it is required to avoid stack overflows.
132
+ */
133
+ circular?: boolean;
134
+ /**
135
+ * Create a custom configuration of type-specific equality comparators.
136
+ * This receives the default configuration, which allows either replacement
137
+ * or supersetting of the default methods.
138
+ */
139
+ createCustomConfig?: CreateCustomComparatorConfig<Meta>;
140
+ /**
141
+ * Create a custom internal comparator, which is used as an override to the
142
+ * default entry point for nested value equality comparisons. This is often
143
+ * used for doing custom logic for specific types (such as handling a specific
144
+ * class instance differently than other objects) or to incorporate `meta` in
145
+ * the comparison. See the recipes for examples.
146
+ */
147
+ createInternalComparator?: (compare: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
148
+ /**
149
+ * Create a custom `state` object passed between the methods. This allows for
150
+ * custom `cache` and/or `meta` values to be used.
151
+ */
152
+ createState?: CreateState<Meta>;
153
+ /**
154
+ * Whether the equality comparison is strict, meaning it matches
155
+ * all properties (including symbols and non-enumerable properties)
156
+ * with equal shape of descriptors.
157
+ */
158
+ strict?: boolean;
159
+ }
160
+
161
+ /**
162
+ * Whether the values passed are strictly equal or both NaN.
163
+ */
164
+ declare function sameValueZeroEqual(a: any, b: any): boolean;
165
+
22
166
  /**
23
167
  * Whether the items passed are deeply-equal in value.
24
168
  */
25
- export declare const deepEqual: <A, B>(a: A, b: B) => boolean;
169
+ declare const deepEqual: <A, B>(a: A, b: B) => boolean;
26
170
  /**
27
171
  * Whether the items passed are deeply-equal in value based on strict comparison.
28
172
  */
29
- export declare const strictDeepEqual: <A, B>(a: A, b: B) => boolean;
173
+ declare const strictDeepEqual: <A, B>(a: A, b: B) => boolean;
30
174
  /**
31
175
  * Whether the items passed are deeply-equal in value, including circular references.
32
176
  */
33
- export declare const circularDeepEqual: <A, B>(a: A, b: B) => boolean;
177
+ declare const circularDeepEqual: <A, B>(a: A, b: B) => boolean;
34
178
  /**
35
179
  * Whether the items passed are deeply-equal in value, including circular references,
36
180
  * based on strict comparison.
37
181
  */
38
- export declare const strictCircularDeepEqual: <A, B>(a: A, b: B) => boolean;
182
+ declare const strictCircularDeepEqual: <A, B>(a: A, b: B) => boolean;
39
183
  /**
40
184
  * Whether the items passed are shallowly-equal in value.
41
185
  */
42
- export declare const shallowEqual: <A, B>(a: A, b: B) => boolean;
186
+ declare const shallowEqual: <A, B>(a: A, b: B) => boolean;
43
187
  /**
44
188
  * Whether the items passed are shallowly-equal in value based on strict comparison
45
189
  */
46
- export declare const strictShallowEqual: <A, B>(a: A, b: B) => boolean;
190
+ declare const strictShallowEqual: <A, B>(a: A, b: B) => boolean;
47
191
  /**
48
192
  * Whether the items passed are shallowly-equal in value, including circular references.
49
193
  */
50
- export declare const circularShallowEqual: <A, B>(a: A, b: B) => boolean;
194
+ declare const circularShallowEqual: <A, B>(a: A, b: B) => boolean;
51
195
  /**
52
196
  * Whether the items passed are shallowly-equal in value, including circular references,
53
197
  * based on strict comparison.
54
198
  */
55
- export declare const strictCircularShallowEqual: <A, B>(a: A, b: B) => boolean;
199
+ declare const strictCircularShallowEqual: <A, B>(a: A, b: B) => boolean;
56
200
  /**
57
201
  * Create a custom equality comparison method.
58
202
  *
@@ -61,6 +205,7 @@ export declare const strictCircularShallowEqual: <A, B>(a: A, b: B) => boolean;
61
205
  * support for legacy environments that do not support expected features like
62
206
  * `RegExp.prototype.flags` out of the box.
63
207
  */
64
- export declare function createCustomEqual<Meta = undefined>(
65
- options?: CustomEqualCreatorOptions<Meta>,
66
- ): <A, B>(a: A, b: B) => boolean;
208
+ declare function createCustomEqual<Meta = undefined>(options?: CustomEqualCreatorOptions<Meta>): <A, B>(a: A, b: B) => boolean;
209
+
210
+ export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };
211
+ export type { AnyEqualityComparator, Cache, CircularState, ComparatorConfig, CreateCustomComparatorConfig, CreateState, CustomEqualCreatorOptions, DefaultState, Dictionary, EqualityComparator, EqualityComparatorCreator, InternalEqualityComparator, PrimitiveWrapper, State, TypeEqualityComparator, TypedArray };
@@ -1,58 +1,202 @@
1
- import type { CustomEqualCreatorOptions } from './internalTypes.d.mts';
2
- import type { sameValueZeroEqual } from './utils.d.mts';
3
- export { sameValueZeroEqual };
4
- export type {
5
- AnyEqualityComparator,
6
- Cache,
7
- CircularState,
8
- ComparatorConfig,
9
- CreateCustomComparatorConfig,
10
- CreateState,
11
- CustomEqualCreatorOptions,
12
- DefaultState,
13
- Dictionary,
14
- EqualityComparator,
15
- EqualityComparatorCreator,
16
- InternalEqualityComparator,
17
- PrimitiveWrapper,
18
- State,
19
- TypeEqualityComparator,
20
- TypedArray,
21
- } from './internalTypes.d.mts';
1
+ /**
2
+ * Cache used to store references to objects, used for circular
3
+ * reference checks.
4
+ */
5
+ interface Cache<Key extends object, Value> {
6
+ delete(key: Key): boolean;
7
+ get(key: Key): Value | undefined;
8
+ set(key: Key, value: any): any;
9
+ }
10
+ interface State<Meta> {
11
+ /**
12
+ * Cache used to identify circular references
13
+ */
14
+ readonly cache: Cache<any, any> | undefined;
15
+ /**
16
+ * Method used to determine equality of nested value.
17
+ */
18
+ readonly equals: InternalEqualityComparator<Meta>;
19
+ /**
20
+ * Additional value that can be used for comparisons.
21
+ */
22
+ meta: Meta;
23
+ /**
24
+ * Whether the equality comparison is strict, meaning it matches
25
+ * all properties (including symbols and non-enumerable properties)
26
+ * with equal shape of descriptors.
27
+ */
28
+ readonly strict: boolean;
29
+ }
30
+ interface CircularState<Meta> extends State<Meta> {
31
+ readonly cache: Cache<any, any>;
32
+ }
33
+ interface DefaultState<Meta> extends State<Meta> {
34
+ readonly cache: undefined;
35
+ }
36
+ interface Dictionary<Value = any> {
37
+ [key: string | symbol]: Value;
38
+ $$typeof?: any;
39
+ }
40
+ interface ComparatorConfig<Meta> {
41
+ /**
42
+ * Whether the array buffers passed are equal in value. In strict mode, this includes
43
+ * additional properties added to the array.
44
+ */
45
+ areArrayBuffersEqual: TypeEqualityComparator<any, Meta>;
46
+ /**
47
+ * Whether the arrays passed are equal in value. In strict mode, this includes
48
+ * additional properties added to the array.
49
+ */
50
+ areArraysEqual: TypeEqualityComparator<any, Meta>;
51
+ /**
52
+ * Whether the data views passed are equal in value.
53
+ */
54
+ areDataViewsEqual: TypeEqualityComparator<any, Meta>;
55
+ /**
56
+ * Whether the dates passed are equal in value.
57
+ */
58
+ areDatesEqual: TypeEqualityComparator<any, Meta>;
59
+ /**
60
+ * Whether the errors passed are equal in value.
61
+ */
62
+ areErrorsEqual: TypeEqualityComparator<any, Meta>;
63
+ /**
64
+ * Whether the functions passed are equal in value.
65
+ */
66
+ areFunctionsEqual: TypeEqualityComparator<any, Meta>;
67
+ /**
68
+ * Whether the maps passed are equal in value. In strict mode, this includes
69
+ * additional properties added to the map.
70
+ */
71
+ areMapsEqual: TypeEqualityComparator<any, Meta>;
72
+ /**
73
+ * Whether the numbers passed are equal in value.
74
+ */
75
+ areNumbersEqual: TypeEqualityComparator<any, Meta>;
76
+ /**
77
+ * Whether the objects passed are equal in value. In strict mode, this includes
78
+ * non-enumerable properties added to the map, as well as symbol properties.
79
+ */
80
+ areObjectsEqual: TypeEqualityComparator<any, Meta>;
81
+ /**
82
+ * Whether the primitive wrappers passed are equal in value.
83
+ */
84
+ arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
85
+ /**
86
+ * Whether the regexps passed are equal in value.
87
+ */
88
+ areRegExpsEqual: TypeEqualityComparator<any, Meta>;
89
+ /**
90
+ * Whether the sets passed are equal in value. In strict mode, this includes
91
+ * additional properties added to the set.
92
+ */
93
+ areSetsEqual: TypeEqualityComparator<any, Meta>;
94
+ /**
95
+ * Whether the typed arrays passed are equal in value. In strict mode, this includes
96
+ * additional properties added to the typed array.
97
+ */
98
+ areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
99
+ /**
100
+ * Whether the URLs passed are equal in value.
101
+ */
102
+ areUrlsEqual: TypeEqualityComparator<any, Meta>;
103
+ /**
104
+ * Whether two values with unknown `@@toStringTag` are equal in value. This comparator is
105
+ * called when no other comparator applies.
106
+ *
107
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag
108
+ */
109
+ unknownTagComparators: Record<string, TypeEqualityComparator<any, Meta>> | undefined;
110
+ }
111
+ type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
112
+ type CreateState<Meta> = () => {
113
+ cache?: Cache<any, any> | undefined;
114
+ meta?: Meta;
115
+ };
116
+ type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) => boolean;
117
+ type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
118
+ type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
119
+ type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
120
+ type PrimitiveWrapper = Boolean | Number | String;
121
+ /**
122
+ * Type which encompasses possible instances of TypedArray
123
+ * classes.
124
+ */
125
+ type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
126
+ type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
127
+ interface CustomEqualCreatorOptions<Meta> {
128
+ /**
129
+ * Whether circular references should be supported. It causes the
130
+ * comparison to be slower, but for objects that have circular references
131
+ * it is required to avoid stack overflows.
132
+ */
133
+ circular?: boolean;
134
+ /**
135
+ * Create a custom configuration of type-specific equality comparators.
136
+ * This receives the default configuration, which allows either replacement
137
+ * or supersetting of the default methods.
138
+ */
139
+ createCustomConfig?: CreateCustomComparatorConfig<Meta>;
140
+ /**
141
+ * Create a custom internal comparator, which is used as an override to the
142
+ * default entry point for nested value equality comparisons. This is often
143
+ * used for doing custom logic for specific types (such as handling a specific
144
+ * class instance differently than other objects) or to incorporate `meta` in
145
+ * the comparison. See the recipes for examples.
146
+ */
147
+ createInternalComparator?: (compare: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
148
+ /**
149
+ * Create a custom `state` object passed between the methods. This allows for
150
+ * custom `cache` and/or `meta` values to be used.
151
+ */
152
+ createState?: CreateState<Meta>;
153
+ /**
154
+ * Whether the equality comparison is strict, meaning it matches
155
+ * all properties (including symbols and non-enumerable properties)
156
+ * with equal shape of descriptors.
157
+ */
158
+ strict?: boolean;
159
+ }
160
+
161
+ /**
162
+ * Whether the values passed are strictly equal or both NaN.
163
+ */
164
+ declare function sameValueZeroEqual(a: any, b: any): boolean;
165
+
22
166
  /**
23
167
  * Whether the items passed are deeply-equal in value.
24
168
  */
25
- export declare const deepEqual: <A, B>(a: A, b: B) => boolean;
169
+ declare const deepEqual: <A, B>(a: A, b: B) => boolean;
26
170
  /**
27
171
  * Whether the items passed are deeply-equal in value based on strict comparison.
28
172
  */
29
- export declare const strictDeepEqual: <A, B>(a: A, b: B) => boolean;
173
+ declare const strictDeepEqual: <A, B>(a: A, b: B) => boolean;
30
174
  /**
31
175
  * Whether the items passed are deeply-equal in value, including circular references.
32
176
  */
33
- export declare const circularDeepEqual: <A, B>(a: A, b: B) => boolean;
177
+ declare const circularDeepEqual: <A, B>(a: A, b: B) => boolean;
34
178
  /**
35
179
  * Whether the items passed are deeply-equal in value, including circular references,
36
180
  * based on strict comparison.
37
181
  */
38
- export declare const strictCircularDeepEqual: <A, B>(a: A, b: B) => boolean;
182
+ declare const strictCircularDeepEqual: <A, B>(a: A, b: B) => boolean;
39
183
  /**
40
184
  * Whether the items passed are shallowly-equal in value.
41
185
  */
42
- export declare const shallowEqual: <A, B>(a: A, b: B) => boolean;
186
+ declare const shallowEqual: <A, B>(a: A, b: B) => boolean;
43
187
  /**
44
188
  * Whether the items passed are shallowly-equal in value based on strict comparison
45
189
  */
46
- export declare const strictShallowEqual: <A, B>(a: A, b: B) => boolean;
190
+ declare const strictShallowEqual: <A, B>(a: A, b: B) => boolean;
47
191
  /**
48
192
  * Whether the items passed are shallowly-equal in value, including circular references.
49
193
  */
50
- export declare const circularShallowEqual: <A, B>(a: A, b: B) => boolean;
194
+ declare const circularShallowEqual: <A, B>(a: A, b: B) => boolean;
51
195
  /**
52
196
  * Whether the items passed are shallowly-equal in value, including circular references,
53
197
  * based on strict comparison.
54
198
  */
55
- export declare const strictCircularShallowEqual: <A, B>(a: A, b: B) => boolean;
199
+ declare const strictCircularShallowEqual: <A, B>(a: A, b: B) => boolean;
56
200
  /**
57
201
  * Create a custom equality comparison method.
58
202
  *
@@ -61,6 +205,7 @@ export declare const strictCircularShallowEqual: <A, B>(a: A, b: B) => boolean;
61
205
  * support for legacy environments that do not support expected features like
62
206
  * `RegExp.prototype.flags` out of the box.
63
207
  */
64
- export declare function createCustomEqual<Meta = undefined>(
65
- options?: CustomEqualCreatorOptions<Meta>,
66
- ): <A, B>(a: A, b: B) => boolean;
208
+ declare function createCustomEqual<Meta = undefined>(options?: CustomEqualCreatorOptions<Meta>): <A, B>(a: A, b: B) => boolean;
209
+
210
+ export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };
211
+ export type { AnyEqualityComparator, Cache, CircularState, ComparatorConfig, CreateCustomComparatorConfig, CreateState, CustomEqualCreatorOptions, DefaultState, Dictionary, EqualityComparator, EqualityComparatorCreator, InternalEqualityComparator, PrimitiveWrapper, State, TypeEqualityComparator, TypedArray };
package/dist/es/index.mjs CHANGED
@@ -63,6 +63,12 @@ const PREACT_VNODE = '__v';
63
63
  const PREACT_OWNER = '__o';
64
64
  const REACT_OWNER = '_owner';
65
65
  const { getOwnPropertyDescriptor, keys } = Object;
66
+ /**
67
+ * Whether the array buffers are equal in value.
68
+ */
69
+ function areArrayBuffersEqual(a, b) {
70
+ return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
71
+ }
66
72
  /**
67
73
  * Whether the arrays are equal in value.
68
74
  */
@@ -78,6 +84,13 @@ function areArraysEqual(a, b, state) {
78
84
  }
79
85
  return true;
80
86
  }
87
+ /**
88
+ * Whether the dataviews are equal in value.
89
+ */
90
+ function areDataViewsEqual(a, b) {
91
+ return (a.byteLength === b.byteLength
92
+ && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength)));
93
+ }
81
94
  /**
82
95
  * Whether the dates passed are equal in value.
83
96
  */
@@ -260,8 +273,8 @@ function areSetsEqual(a, b, state) {
260
273
  * Whether the TypedArray instances are equal in value.
261
274
  */
262
275
  function areTypedArraysEqual(a, b) {
263
- let index = a.length;
264
- if (b.length !== index) {
276
+ let index = a.byteLength;
277
+ if (b.byteLength !== index || a.byteOffset !== b.byteOffset) {
265
278
  return false;
266
279
  }
267
280
  while (index-- > 0) {
@@ -291,8 +304,10 @@ function isPropertyEqual(a, b, state, property) {
291
304
  return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
292
305
  }
293
306
 
307
+ const ARRAY_BUFFER_TAG = '[object ArrayBuffer]';
294
308
  const ARGUMENTS_TAG = '[object Arguments]';
295
309
  const BOOLEAN_TAG = '[object Boolean]';
310
+ const DATA_VIEW_TAG = '[object DataView]';
296
311
  const DATE_TAG = '[object Date]';
297
312
  const ERROR_TAG = '[object Error]';
298
313
  const MAP_TAG = '[object Map]';
@@ -301,18 +316,27 @@ const OBJECT_TAG = '[object Object]';
301
316
  const REG_EXP_TAG = '[object RegExp]';
302
317
  const SET_TAG = '[object Set]';
303
318
  const STRING_TAG = '[object String]';
319
+ const TYPED_ARRAY_TAGS = {
320
+ '[object Int8Array]': true,
321
+ '[object Uint8Array]': true,
322
+ '[object Uint8ClampedArray]': true,
323
+ '[object Int16Array]': true,
324
+ '[object Uint16Array]': true,
325
+ '[object Int32Array]': true,
326
+ '[object Uint32Array]': true,
327
+ '[object Float16Array]': true,
328
+ '[object Float32Array]': true,
329
+ '[object Float64Array]': true,
330
+ '[object BigInt64Array]': true,
331
+ '[object BigUint64Array]': true,
332
+ };
304
333
  const URL_TAG = '[object URL]';
305
- const { isArray } = Array;
306
- const isTypedArray =
307
334
  // eslint-disable-next-line @typescript-eslint/unbound-method
308
- typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView : null;
309
- const { assign } = Object;
310
- // eslint-disable-next-line @typescript-eslint/unbound-method
311
- const getTag = Object.prototype.toString.call.bind(Object.prototype.toString);
335
+ const toString = Object.prototype.toString;
312
336
  /**
313
337
  * Create a comparator method based on the type-specific equality comparators passed.
314
338
  */
315
- function createEqualityComparator({ areArraysEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, unknownTagComparators, }) {
339
+ function createEqualityComparator({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, unknownTagComparators, }) {
316
340
  /**
317
341
  * compare the value of the two objects and return true if they are equivalent in values
318
342
  */
@@ -362,14 +386,9 @@ function createEqualityComparator({ areArraysEqual, areDatesEqual, areErrorsEqua
362
386
  }
363
387
  // `isArray()` works on subclasses and is cross-realm, so we can avoid capturing
364
388
  // the string tag or doing an `instanceof` check.
365
- if (isArray(a)) {
389
+ if (Array.isArray(a)) {
366
390
  return areArraysEqual(a, b, state);
367
391
  }
368
- // `isTypedArray()` works on all possible TypedArray classes, so we can avoid
369
- // capturing the string tag or comparing against all possible constructors.
370
- if (isTypedArray != null && isTypedArray(a)) {
371
- return areTypedArraysEqual(a, b, state);
372
- }
373
392
  // Try to fast-path equality checks for other complex object types in the
374
393
  // same realm to avoid capturing the string tag. Strict equality is used
375
394
  // instead of `instanceof` because it is more performant for the common
@@ -389,7 +408,7 @@ function createEqualityComparator({ areArraysEqual, areDatesEqual, areErrorsEqua
389
408
  }
390
409
  // Since this is a custom object, capture the string tag to determing its type.
391
410
  // This is reasonably performant in modern environments like v8 and SpiderMonkey.
392
- const tag = getTag(a);
411
+ const tag = toString.call(a);
393
412
  if (tag === DATE_TAG) {
394
413
  return areDatesEqual(a, b, state);
395
414
  }
@@ -424,6 +443,15 @@ function createEqualityComparator({ areArraysEqual, areDatesEqual, areErrorsEqua
424
443
  if (tag === ARGUMENTS_TAG) {
425
444
  return areObjectsEqual(a, b, state);
426
445
  }
446
+ if (TYPED_ARRAY_TAGS[tag]) {
447
+ return areTypedArraysEqual(a, b, state);
448
+ }
449
+ if (tag === ARRAY_BUFFER_TAG) {
450
+ return areArrayBuffersEqual(a, b, state);
451
+ }
452
+ if (tag === DATA_VIEW_TAG) {
453
+ return areDataViewsEqual(a, b, state);
454
+ }
427
455
  // As the penultimate fallback, check if the values passed are primitive wrappers. This
428
456
  // is very rare in modern JS, which is why it is deprioritized compared to all other object
429
457
  // types.
@@ -463,7 +491,9 @@ function createEqualityComparator({ areArraysEqual, areDatesEqual, areErrorsEqua
463
491
  */
464
492
  function createEqualityComparatorConfig({ circular, createCustomConfig, strict, }) {
465
493
  let config = {
494
+ areArrayBuffersEqual,
466
495
  areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
496
+ areDataViewsEqual,
467
497
  areDatesEqual: areDatesEqual,
468
498
  areErrorsEqual: areErrorsEqual,
469
499
  areFunctionsEqual: areFunctionsEqual,
@@ -473,19 +503,21 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict,
473
503
  arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,
474
504
  areRegExpsEqual: areRegExpsEqual,
475
505
  areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
476
- areTypedArraysEqual: strict ? areObjectsEqualStrict : areTypedArraysEqual,
506
+ areTypedArraysEqual: strict
507
+ ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict)
508
+ : areTypedArraysEqual,
477
509
  areUrlsEqual: areUrlsEqual,
478
510
  unknownTagComparators: undefined,
479
511
  };
480
512
  if (createCustomConfig) {
481
- config = assign({}, config, createCustomConfig(config));
513
+ config = Object.assign({}, config, createCustomConfig(config));
482
514
  }
483
515
  if (circular) {
484
516
  const areArraysEqual = createIsCircular(config.areArraysEqual);
485
517
  const areMapsEqual = createIsCircular(config.areMapsEqual);
486
518
  const areObjectsEqual = createIsCircular(config.areObjectsEqual);
487
519
  const areSetsEqual = createIsCircular(config.areSetsEqual);
488
- config = assign({}, config, {
520
+ config = Object.assign({}, config, {
489
521
  areArraysEqual,
490
522
  areMapsEqual,
491
523
  areObjectsEqual,