@cjser/fast-equals__v5_4_1 5.4.1-cjser.2

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.
@@ -0,0 +1,653 @@
1
+ 'use strict';
2
+
3
+ const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
4
+ // eslint-disable-next-line @typescript-eslint/unbound-method
5
+ const { hasOwnProperty } = Object.prototype;
6
+ /**
7
+ * Combine two comparators into a single comparators.
8
+ */
9
+ function combineComparators(comparatorA, comparatorB) {
10
+ return function isEqual(a, b, state) {
11
+ return comparatorA(a, b, state) && comparatorB(a, b, state);
12
+ };
13
+ }
14
+ /**
15
+ * Wrap the provided `areItemsEqual` method to manage the circular state, allowing
16
+ * for circular references to be safely included in the comparison without creating
17
+ * stack overflows.
18
+ */
19
+ function createIsCircular(areItemsEqual) {
20
+ return function isCircular(a, b, state) {
21
+ if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {
22
+ return areItemsEqual(a, b, state);
23
+ }
24
+ const { cache } = state;
25
+ const cachedA = cache.get(a);
26
+ const cachedB = cache.get(b);
27
+ if (cachedA && cachedB) {
28
+ return cachedA === b && cachedB === a;
29
+ }
30
+ cache.set(a, b);
31
+ cache.set(b, a);
32
+ const result = areItemsEqual(a, b, state);
33
+ cache.delete(a);
34
+ cache.delete(b);
35
+ return result;
36
+ };
37
+ }
38
+ /**
39
+ * Get the `@@toStringTag` of the value, if it exists.
40
+ */
41
+ function getShortTag(value) {
42
+ return value != null ? value[Symbol.toStringTag] : undefined;
43
+ }
44
+ /**
45
+ * Get the properties to strictly examine, which include both own properties that are
46
+ * not enumerable and symbol properties.
47
+ */
48
+ function getStrictProperties(object) {
49
+ return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
50
+ }
51
+ /**
52
+ * Whether the object contains the property passed as an own property.
53
+ */
54
+ const hasOwn =
55
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
56
+ Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property));
57
+ /**
58
+ * Whether the values passed are strictly equal or both NaN.
59
+ */
60
+ function sameValueZeroEqual(a, b) {
61
+ return a === b || (!a && !b && a !== a && b !== b);
62
+ }
63
+
64
+ const PREACT_VNODE = '__v';
65
+ const PREACT_OWNER = '__o';
66
+ const REACT_OWNER = '_owner';
67
+ const { getOwnPropertyDescriptor, keys } = Object;
68
+ /**
69
+ * Whether the array buffers are equal in value.
70
+ */
71
+ function areArrayBuffersEqual(a, b) {
72
+ return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
73
+ }
74
+ /**
75
+ * Whether the arrays are equal in value.
76
+ */
77
+ function areArraysEqual(a, b, state) {
78
+ let index = a.length;
79
+ if (b.length !== index) {
80
+ return false;
81
+ }
82
+ while (index-- > 0) {
83
+ if (!state.equals(a[index], b[index], index, index, a, b, state)) {
84
+ return false;
85
+ }
86
+ }
87
+ return true;
88
+ }
89
+ /**
90
+ * Whether the dataviews are equal in value.
91
+ */
92
+ function areDataViewsEqual(a, b) {
93
+ return (a.byteLength === b.byteLength
94
+ && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength)));
95
+ }
96
+ /**
97
+ * Whether the dates passed are equal in value.
98
+ */
99
+ function areDatesEqual(a, b) {
100
+ return sameValueZeroEqual(a.getTime(), b.getTime());
101
+ }
102
+ /**
103
+ * Whether the errors passed are equal in value.
104
+ */
105
+ function areErrorsEqual(a, b) {
106
+ return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
107
+ }
108
+ /**
109
+ * Whether the functions passed are equal in value.
110
+ */
111
+ function areFunctionsEqual(a, b) {
112
+ return a === b;
113
+ }
114
+ /**
115
+ * Whether the `Map`s are equal in value.
116
+ */
117
+ function areMapsEqual(a, b, state) {
118
+ const size = a.size;
119
+ if (size !== b.size) {
120
+ return false;
121
+ }
122
+ if (!size) {
123
+ return true;
124
+ }
125
+ const matchedIndices = new Array(size);
126
+ const aIterable = a.entries();
127
+ let aResult;
128
+ let bResult;
129
+ let index = 0;
130
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
131
+ while ((aResult = aIterable.next())) {
132
+ if (aResult.done) {
133
+ break;
134
+ }
135
+ const bIterable = b.entries();
136
+ let hasMatch = false;
137
+ let matchIndex = 0;
138
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
139
+ while ((bResult = bIterable.next())) {
140
+ if (bResult.done) {
141
+ break;
142
+ }
143
+ if (matchedIndices[matchIndex]) {
144
+ matchIndex++;
145
+ continue;
146
+ }
147
+ const aEntry = aResult.value;
148
+ const bEntry = bResult.value;
149
+ if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state)
150
+ && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
151
+ hasMatch = matchedIndices[matchIndex] = true;
152
+ break;
153
+ }
154
+ matchIndex++;
155
+ }
156
+ if (!hasMatch) {
157
+ return false;
158
+ }
159
+ index++;
160
+ }
161
+ return true;
162
+ }
163
+ /**
164
+ * Whether the numbers are equal in value.
165
+ */
166
+ const areNumbersEqual = sameValueZeroEqual;
167
+ /**
168
+ * Whether the objects are equal in value.
169
+ */
170
+ function areObjectsEqual(a, b, state) {
171
+ const properties = keys(a);
172
+ let index = properties.length;
173
+ if (keys(b).length !== index) {
174
+ return false;
175
+ }
176
+ // Decrementing `while` showed faster results than either incrementing or
177
+ // decrementing `for` loop and than an incrementing `while` loop. Declarative
178
+ // methods like `some` / `every` were not used to avoid incurring the garbage
179
+ // cost of anonymous callbacks.
180
+ while (index-- > 0) {
181
+ if (!isPropertyEqual(a, b, state, properties[index])) {
182
+ return false;
183
+ }
184
+ }
185
+ return true;
186
+ }
187
+ /**
188
+ * Whether the objects are equal in value with strict property checking.
189
+ */
190
+ function areObjectsEqualStrict(a, b, state) {
191
+ const properties = getStrictProperties(a);
192
+ let index = properties.length;
193
+ if (getStrictProperties(b).length !== index) {
194
+ return false;
195
+ }
196
+ let property;
197
+ let descriptorA;
198
+ let descriptorB;
199
+ // Decrementing `while` showed faster results than either incrementing or
200
+ // decrementing `for` loop and than an incrementing `while` loop. Declarative
201
+ // methods like `some` / `every` were not used to avoid incurring the garbage
202
+ // cost of anonymous callbacks.
203
+ while (index-- > 0) {
204
+ property = properties[index];
205
+ if (!isPropertyEqual(a, b, state, property)) {
206
+ return false;
207
+ }
208
+ descriptorA = getOwnPropertyDescriptor(a, property);
209
+ descriptorB = getOwnPropertyDescriptor(b, property);
210
+ if ((descriptorA || descriptorB)
211
+ && (!descriptorA
212
+ || !descriptorB
213
+ || descriptorA.configurable !== descriptorB.configurable
214
+ || descriptorA.enumerable !== descriptorB.enumerable
215
+ || descriptorA.writable !== descriptorB.writable)) {
216
+ return false;
217
+ }
218
+ }
219
+ return true;
220
+ }
221
+ /**
222
+ * Whether the primitive wrappers passed are equal in value.
223
+ */
224
+ function arePrimitiveWrappersEqual(a, b) {
225
+ return sameValueZeroEqual(a.valueOf(), b.valueOf());
226
+ }
227
+ /**
228
+ * Whether the regexps passed are equal in value.
229
+ */
230
+ function areRegExpsEqual(a, b) {
231
+ return a.source === b.source && a.flags === b.flags;
232
+ }
233
+ /**
234
+ * Whether the `Set`s are equal in value.
235
+ */
236
+ function areSetsEqual(a, b, state) {
237
+ const size = a.size;
238
+ if (size !== b.size) {
239
+ return false;
240
+ }
241
+ if (!size) {
242
+ return true;
243
+ }
244
+ const matchedIndices = new Array(size);
245
+ const aIterable = a.values();
246
+ let aResult;
247
+ let bResult;
248
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
249
+ while ((aResult = aIterable.next())) {
250
+ if (aResult.done) {
251
+ break;
252
+ }
253
+ const bIterable = b.values();
254
+ let hasMatch = false;
255
+ let matchIndex = 0;
256
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
257
+ while ((bResult = bIterable.next())) {
258
+ if (bResult.done) {
259
+ break;
260
+ }
261
+ if (!matchedIndices[matchIndex]
262
+ && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
263
+ hasMatch = matchedIndices[matchIndex] = true;
264
+ break;
265
+ }
266
+ matchIndex++;
267
+ }
268
+ if (!hasMatch) {
269
+ return false;
270
+ }
271
+ }
272
+ return true;
273
+ }
274
+ /**
275
+ * Whether the TypedArray instances are equal in value.
276
+ */
277
+ function areTypedArraysEqual(a, b) {
278
+ let index = a.byteLength;
279
+ if (b.byteLength !== index || a.byteOffset !== b.byteOffset) {
280
+ return false;
281
+ }
282
+ while (index-- > 0) {
283
+ if (a[index] !== b[index]) {
284
+ return false;
285
+ }
286
+ }
287
+ return true;
288
+ }
289
+ /**
290
+ * Whether the URL instances are equal in value.
291
+ */
292
+ function areUrlsEqual(a, b) {
293
+ return (a.hostname === b.hostname
294
+ && a.pathname === b.pathname
295
+ && a.protocol === b.protocol
296
+ && a.port === b.port
297
+ && a.hash === b.hash
298
+ && a.username === b.username
299
+ && a.password === b.password);
300
+ }
301
+ function isPropertyEqual(a, b, state, property) {
302
+ if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE)
303
+ && (a.$$typeof || b.$$typeof)) {
304
+ return true;
305
+ }
306
+ return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
307
+ }
308
+
309
+ const ARRAY_BUFFER_TAG = '[object ArrayBuffer]';
310
+ const ARGUMENTS_TAG = '[object Arguments]';
311
+ const BOOLEAN_TAG = '[object Boolean]';
312
+ const DATA_VIEW_TAG = '[object DataView]';
313
+ const DATE_TAG = '[object Date]';
314
+ const ERROR_TAG = '[object Error]';
315
+ const MAP_TAG = '[object Map]';
316
+ const NUMBER_TAG = '[object Number]';
317
+ const OBJECT_TAG = '[object Object]';
318
+ const REG_EXP_TAG = '[object RegExp]';
319
+ const SET_TAG = '[object Set]';
320
+ const STRING_TAG = '[object String]';
321
+ const TYPED_ARRAY_TAGS = {
322
+ '[object Int8Array]': true,
323
+ '[object Uint8Array]': true,
324
+ '[object Uint8ClampedArray]': true,
325
+ '[object Int16Array]': true,
326
+ '[object Uint16Array]': true,
327
+ '[object Int32Array]': true,
328
+ '[object Uint32Array]': true,
329
+ '[object Float16Array]': true,
330
+ '[object Float32Array]': true,
331
+ '[object Float64Array]': true,
332
+ '[object BigInt64Array]': true,
333
+ '[object BigUint64Array]': true,
334
+ };
335
+ const URL_TAG = '[object URL]';
336
+ // eslint-disable-next-line @typescript-eslint/unbound-method
337
+ const toString = Object.prototype.toString;
338
+ /**
339
+ * Create a comparator method based on the type-specific equality comparators passed.
340
+ */
341
+ function createEqualityComparator({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, unknownTagComparators, }) {
342
+ /**
343
+ * compare the value of the two objects and return true if they are equivalent in values
344
+ */
345
+ return function comparator(a, b, state) {
346
+ // If the items are strictly equal, no need to do a value comparison.
347
+ if (a === b) {
348
+ return true;
349
+ }
350
+ // If either of the items are nullish and fail the strictly equal check
351
+ // above, then they must be unequal.
352
+ if (a == null || b == null) {
353
+ return false;
354
+ }
355
+ const type = typeof a;
356
+ if (type !== typeof b) {
357
+ return false;
358
+ }
359
+ if (type !== 'object') {
360
+ if (type === 'number') {
361
+ return areNumbersEqual(a, b, state);
362
+ }
363
+ if (type === 'function') {
364
+ return areFunctionsEqual(a, b, state);
365
+ }
366
+ // If a primitive value that is not strictly equal, it must be unequal.
367
+ return false;
368
+ }
369
+ const constructor = a.constructor;
370
+ // Checks are listed in order of commonality of use-case:
371
+ // 1. Common complex object types (plain object, array)
372
+ // 2. Common data values (date, regexp)
373
+ // 3. Less-common complex object types (map, set)
374
+ // 4. Less-common data values (promise, primitive wrappers)
375
+ // Inherently this is both subjective and assumptive, however
376
+ // when reviewing comparable libraries in the wild this order
377
+ // appears to be generally consistent.
378
+ // Constructors should match, otherwise there is potential for false positives
379
+ // between class and subclass or custom object and POJO.
380
+ if (constructor !== b.constructor) {
381
+ return false;
382
+ }
383
+ // `isPlainObject` only checks against the object's own realm. Cross-realm
384
+ // comparisons are rare, and will be handled in the ultimate fallback, so
385
+ // we can avoid capturing the string tag.
386
+ if (constructor === Object) {
387
+ return areObjectsEqual(a, b, state);
388
+ }
389
+ // `isArray()` works on subclasses and is cross-realm, so we can avoid capturing
390
+ // the string tag or doing an `instanceof` check.
391
+ if (Array.isArray(a)) {
392
+ return areArraysEqual(a, b, state);
393
+ }
394
+ // Try to fast-path equality checks for other complex object types in the
395
+ // same realm to avoid capturing the string tag. Strict equality is used
396
+ // instead of `instanceof` because it is more performant for the common
397
+ // use-case. If someone is subclassing a native class, it will be handled
398
+ // with the string tag comparison.
399
+ if (constructor === Date) {
400
+ return areDatesEqual(a, b, state);
401
+ }
402
+ if (constructor === RegExp) {
403
+ return areRegExpsEqual(a, b, state);
404
+ }
405
+ if (constructor === Map) {
406
+ return areMapsEqual(a, b, state);
407
+ }
408
+ if (constructor === Set) {
409
+ return areSetsEqual(a, b, state);
410
+ }
411
+ // Since this is a custom object, capture the string tag to determing its type.
412
+ // This is reasonably performant in modern environments like v8 and SpiderMonkey.
413
+ const tag = toString.call(a);
414
+ if (tag === DATE_TAG) {
415
+ return areDatesEqual(a, b, state);
416
+ }
417
+ // For RegExp, the properties are not enumerable, and therefore will give false positives if
418
+ // tested like a standard object.
419
+ if (tag === REG_EXP_TAG) {
420
+ return areRegExpsEqual(a, b, state);
421
+ }
422
+ if (tag === MAP_TAG) {
423
+ return areMapsEqual(a, b, state);
424
+ }
425
+ if (tag === SET_TAG) {
426
+ return areSetsEqual(a, b, state);
427
+ }
428
+ if (tag === OBJECT_TAG) {
429
+ // The exception for value comparison is custom `Promise`-like class instances. These should
430
+ // be treated the same as standard `Promise` objects, which means strict equality, and if
431
+ // it reaches this point then that strict equality comparison has already failed.
432
+ return typeof a.then !== 'function' && typeof b.then !== 'function' && areObjectsEqual(a, b, state);
433
+ }
434
+ // If a URL tag, it should be tested explicitly. Like RegExp, the properties are not
435
+ // enumerable, and therefore will give false positives if tested like a standard object.
436
+ if (tag === URL_TAG) {
437
+ return areUrlsEqual(a, b, state);
438
+ }
439
+ // If an error tag, it should be tested explicitly. Like RegExp, the properties are not
440
+ // enumerable, and therefore will give false positives if tested like a standard object.
441
+ if (tag === ERROR_TAG) {
442
+ return areErrorsEqual(a, b, state);
443
+ }
444
+ // If an arguments tag, it should be treated as a standard object.
445
+ if (tag === ARGUMENTS_TAG) {
446
+ return areObjectsEqual(a, b, state);
447
+ }
448
+ if (TYPED_ARRAY_TAGS[tag]) {
449
+ return areTypedArraysEqual(a, b, state);
450
+ }
451
+ if (tag === ARRAY_BUFFER_TAG) {
452
+ return areArrayBuffersEqual(a, b, state);
453
+ }
454
+ if (tag === DATA_VIEW_TAG) {
455
+ return areDataViewsEqual(a, b, state);
456
+ }
457
+ // As the penultimate fallback, check if the values passed are primitive wrappers. This
458
+ // is very rare in modern JS, which is why it is deprioritized compared to all other object
459
+ // types.
460
+ if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {
461
+ return arePrimitiveWrappersEqual(a, b, state);
462
+ }
463
+ if (unknownTagComparators) {
464
+ let unknownTagComparator = unknownTagComparators[tag];
465
+ if (!unknownTagComparator) {
466
+ const shortTag = getShortTag(a);
467
+ if (shortTag) {
468
+ unknownTagComparator = unknownTagComparators[shortTag];
469
+ }
470
+ }
471
+ // If the custom config has an unknown tag comparator that matches the captured tag or the
472
+ // @@toStringTag, it is the source of truth for whether the values are equal.
473
+ if (unknownTagComparator) {
474
+ return unknownTagComparator(a, b, state);
475
+ }
476
+ }
477
+ // If not matching any tags that require a specific type of comparison, then we hard-code false because
478
+ // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:
479
+ // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only
480
+ // comparison that can be made.
481
+ // - For types that can be introspected, but rarely have requirements to be compared
482
+ // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common
483
+ // use-cases (may be included in a future release, if requested enough).
484
+ // - For types that can be introspected but do not have an objective definition of what
485
+ // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.
486
+ // In all cases, these decisions should be reevaluated based on changes to the language and
487
+ // common development practices.
488
+ return false;
489
+ };
490
+ }
491
+ /**
492
+ * Create the configuration object used for building comparators.
493
+ */
494
+ function createEqualityComparatorConfig({ circular, createCustomConfig, strict, }) {
495
+ let config = {
496
+ areArrayBuffersEqual,
497
+ areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
498
+ areDataViewsEqual,
499
+ areDatesEqual: areDatesEqual,
500
+ areErrorsEqual: areErrorsEqual,
501
+ areFunctionsEqual: areFunctionsEqual,
502
+ areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
503
+ areNumbersEqual: areNumbersEqual,
504
+ areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
505
+ arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,
506
+ areRegExpsEqual: areRegExpsEqual,
507
+ areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
508
+ areTypedArraysEqual: strict
509
+ ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict)
510
+ : areTypedArraysEqual,
511
+ areUrlsEqual: areUrlsEqual,
512
+ unknownTagComparators: undefined,
513
+ };
514
+ if (createCustomConfig) {
515
+ config = Object.assign({}, config, createCustomConfig(config));
516
+ }
517
+ if (circular) {
518
+ const areArraysEqual = createIsCircular(config.areArraysEqual);
519
+ const areMapsEqual = createIsCircular(config.areMapsEqual);
520
+ const areObjectsEqual = createIsCircular(config.areObjectsEqual);
521
+ const areSetsEqual = createIsCircular(config.areSetsEqual);
522
+ config = Object.assign({}, config, {
523
+ areArraysEqual,
524
+ areMapsEqual,
525
+ areObjectsEqual,
526
+ areSetsEqual,
527
+ });
528
+ }
529
+ return config;
530
+ }
531
+ /**
532
+ * Default equality comparator pass-through, used as the standard `isEqual` creator for
533
+ * use inside the built comparator.
534
+ */
535
+ function createInternalEqualityComparator(compare) {
536
+ return function (a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {
537
+ return compare(a, b, state);
538
+ };
539
+ }
540
+ /**
541
+ * Create the `isEqual` function used by the consuming application.
542
+ */
543
+ function createIsEqual({ circular, comparator, createState, equals, strict }) {
544
+ if (createState) {
545
+ return function isEqual(a, b) {
546
+ const { cache = circular ? new WeakMap() : undefined, meta } = createState();
547
+ return comparator(a, b, {
548
+ cache,
549
+ equals,
550
+ meta,
551
+ strict,
552
+ });
553
+ };
554
+ }
555
+ if (circular) {
556
+ return function isEqual(a, b) {
557
+ return comparator(a, b, {
558
+ cache: new WeakMap(),
559
+ equals,
560
+ meta: undefined,
561
+ strict,
562
+ });
563
+ };
564
+ }
565
+ const state = {
566
+ cache: undefined,
567
+ equals,
568
+ meta: undefined,
569
+ strict,
570
+ };
571
+ return function isEqual(a, b) {
572
+ return comparator(a, b, state);
573
+ };
574
+ }
575
+
576
+ /**
577
+ * Whether the items passed are deeply-equal in value.
578
+ */
579
+ const deepEqual = createCustomEqual();
580
+ /**
581
+ * Whether the items passed are deeply-equal in value based on strict comparison.
582
+ */
583
+ const strictDeepEqual = createCustomEqual({ strict: true });
584
+ /**
585
+ * Whether the items passed are deeply-equal in value, including circular references.
586
+ */
587
+ const circularDeepEqual = createCustomEqual({ circular: true });
588
+ /**
589
+ * Whether the items passed are deeply-equal in value, including circular references,
590
+ * based on strict comparison.
591
+ */
592
+ const strictCircularDeepEqual = createCustomEqual({
593
+ circular: true,
594
+ strict: true,
595
+ });
596
+ /**
597
+ * Whether the items passed are shallowly-equal in value.
598
+ */
599
+ const shallowEqual = createCustomEqual({
600
+ createInternalComparator: () => sameValueZeroEqual,
601
+ });
602
+ /**
603
+ * Whether the items passed are shallowly-equal in value based on strict comparison
604
+ */
605
+ const strictShallowEqual = createCustomEqual({
606
+ strict: true,
607
+ createInternalComparator: () => sameValueZeroEqual,
608
+ });
609
+ /**
610
+ * Whether the items passed are shallowly-equal in value, including circular references.
611
+ */
612
+ const circularShallowEqual = createCustomEqual({
613
+ circular: true,
614
+ createInternalComparator: () => sameValueZeroEqual,
615
+ });
616
+ /**
617
+ * Whether the items passed are shallowly-equal in value, including circular references,
618
+ * based on strict comparison.
619
+ */
620
+ const strictCircularShallowEqual = createCustomEqual({
621
+ circular: true,
622
+ createInternalComparator: () => sameValueZeroEqual,
623
+ strict: true,
624
+ });
625
+ /**
626
+ * Create a custom equality comparison method.
627
+ *
628
+ * This can be done to create very targeted comparisons in extreme hot-path scenarios
629
+ * where the standard methods are not performant enough, but can also be used to provide
630
+ * support for legacy environments that do not support expected features like
631
+ * `RegExp.prototype.flags` out of the box.
632
+ */
633
+ function createCustomEqual(options = {}) {
634
+ const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false, } = options;
635
+ const config = createEqualityComparatorConfig(options);
636
+ const comparator = createEqualityComparator(config);
637
+ const equals = createCustomInternalComparator
638
+ ? createCustomInternalComparator(comparator)
639
+ : createInternalEqualityComparator(comparator);
640
+ return createIsEqual({ circular, comparator, createState, equals, strict });
641
+ }
642
+
643
+ exports.circularDeepEqual = circularDeepEqual;
644
+ exports.circularShallowEqual = circularShallowEqual;
645
+ exports.createCustomEqual = createCustomEqual;
646
+ exports.deepEqual = deepEqual;
647
+ exports.sameValueZeroEqual = sameValueZeroEqual;
648
+ exports.shallowEqual = shallowEqual;
649
+ exports.strictCircularDeepEqual = strictCircularDeepEqual;
650
+ exports.strictCircularShallowEqual = strictCircularShallowEqual;
651
+ exports.strictDeepEqual = strictDeepEqual;
652
+ exports.strictShallowEqual = strictShallowEqual;
653
+ //# sourceMappingURL=index.cjs.map