fast-equals 3.0.1 → 4.0.0-beta.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.
@@ -1,116 +1,190 @@
1
- var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
2
- var keys = Object.keys;
3
1
  /**
4
- * are the values passed strictly equal or both NaN
5
- *
6
- * @param a the value to compare against
7
- * @param b the value to test
8
- * @returns are the values equal by the SameValueZero principle
2
+ * Default equality comparator pass-through, used as the standard `isEqual` creator for
3
+ * use inside the built comparator.
9
4
  */
10
- function sameValueZeroEqual(a, b) {
11
- return a === b || (a !== a && b !== b);
5
+ function createDefaultIsNestedEqual(comparator) {
6
+ return function isEqual(a, b, indexOrKeyA, indexOrKeyB, parentA, parentB, meta) {
7
+ return comparator(a, b, meta);
8
+ };
12
9
  }
13
10
  /**
14
- * is the value a plain object
15
- *
16
- * @param value the value to test
17
- * @returns is the value a plain object
11
+ * Wrap the provided `areItemsEqual` method to manage the circular cache, allowing
12
+ * for circular references to be safely included in the comparison without creating
13
+ * stack overflows.
18
14
  */
19
- function isPlainObject(value) {
20
- return value.constructor === Object || value.constructor == null;
15
+ function createIsCircular(areItemsEqual) {
16
+ return function isCircular(a, b, isEqual, cache) {
17
+ if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {
18
+ return areItemsEqual(a, b, isEqual, cache);
19
+ }
20
+ var cachedA = cache.get(a);
21
+ var cachedB = cache.get(b);
22
+ if (cachedA && cachedB) {
23
+ return cachedA === b && cachedB === a;
24
+ }
25
+ cache.set(a, b);
26
+ cache.set(b, a);
27
+ var result = areItemsEqual(a, b, isEqual, cache);
28
+ cache.delete(a);
29
+ cache.delete(b);
30
+ return result;
31
+ };
21
32
  }
22
33
  /**
23
- * is the value promise-like (meaning it is thenable)
34
+ * Targeted shallow merge of two objects.
24
35
  *
25
- * @param value the value to test
26
- * @returns is the value promise-like
36
+ * @NOTE
37
+ * This exists as a tinier compiled version of the `__assign` helper that
38
+ * `tsc` injects in case of `Object.assign` not being present.
27
39
  */
28
- function isPromiseLike(value) {
29
- return !!value && typeof value.then === 'function';
40
+ function merge(a, b) {
41
+ var merged = {};
42
+ for (var key in a) {
43
+ merged[key] = a[key];
44
+ }
45
+ for (var key in b) {
46
+ merged[key] = b[key];
47
+ }
48
+ return merged;
30
49
  }
31
50
  /**
32
- * is the value passed a react element
51
+ * Whether the value is a plain object.
33
52
  *
34
- * @param value the value to test
35
- * @returns is the value a react element
53
+ * @NOTE
54
+ * This is a same-realm compariosn only.
36
55
  */
37
- function isReactElement(value) {
38
- return !!(value && value.$$typeof);
56
+ function isPlainObject(value) {
57
+ return value.constructor === Object || value.constructor == null;
39
58
  }
40
59
  /**
41
- * in cases where WeakSet is not supported, creates a new custom
42
- * object that mimics the necessary API aspects for cache purposes
43
- *
44
- * @returns the new cache object
60
+ * When the value is `Promise`-like, aka "then-able".
45
61
  */
46
- function getNewCacheFallback() {
47
- var values = [];
48
- return {
49
- add: function (value) {
50
- values.push(value);
51
- },
52
- has: function (value) {
53
- return values.indexOf(value) !== -1;
54
- },
55
- };
62
+ function isPromiseLike(value) {
63
+ return typeof value.then === 'function';
56
64
  }
57
65
  /**
58
- * get a new cache object to prevent circular references
59
- *
60
- * @returns the new cache object
66
+ * Whether the values passed are strictly equal or both NaN.
61
67
  */
62
- var getNewCache = (function (canUseWeakMap) {
63
- if (canUseWeakMap) {
64
- return function _getNewCache() {
65
- return new WeakSet();
66
- };
68
+ function sameValueZeroEqual(a, b) {
69
+ return a === b || (a !== a && b !== b);
70
+ }
71
+
72
+ var ARGUMENTS_TAG = '[object Arguments]';
73
+ var BOOLEAN_TAG = '[object Boolean]';
74
+ var DATE_TAG = '[object Date]';
75
+ var REG_EXP_TAG = '[object RegExp]';
76
+ var MAP_TAG = '[object Map]';
77
+ var NUMBER_TAG = '[object Number]';
78
+ var OBJECT_TAG = '[object Object]';
79
+ var SET_TAG = '[object Set]';
80
+ var STRING_TAG = '[object String]';
81
+ var toString = Object.prototype.toString;
82
+ function createComparator(_a) {
83
+ var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areMapsEqual = _a.areMapsEqual, areObjectsEqual = _a.areObjectsEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, createIsNestedEqual = _a.createIsNestedEqual;
84
+ var isEqual = createIsNestedEqual(comparator);
85
+ /**
86
+ * compare the value of the two objects and return true if they are equivalent in values
87
+ */
88
+ function comparator(a, b, meta) {
89
+ // If the items are strictly equal, no need to do a value comparison.
90
+ if (a === b) {
91
+ return true;
92
+ }
93
+ // If the items are not non-nullish objects, then the only possibility
94
+ // of them being equal but not strictly is if they are both `NaN`. Since
95
+ // `NaN` is uniquely not equal to itself, we can use self-comparison of
96
+ // both objects, which is faster than `isNaN()`.
97
+ if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {
98
+ return a !== a && b !== b;
99
+ }
100
+ // Checks are listed in order of commonality of use-case:
101
+ // 1. Common complex object types (plain object, array)
102
+ // 2. Common data values (date, regexp)
103
+ // 3. Less-common complex object types (map, set)
104
+ // 4. Less-common data values (promise, primitive wrappers)
105
+ // Inherently this is both subjective and assumptive, however
106
+ // when reviewing comparable libraries in the wild this order
107
+ // appears to be generally consistent.
108
+ // `isPlainObject` only checks against the object's own realm. Cross-realm
109
+ // comparisons are rare, and will be handled in the ultimate fallback, so
110
+ // we can avoid the `toString.call()` cost unless necessary.
111
+ if (isPlainObject(a) && isPlainObject(b)) {
112
+ return areObjectsEqual(a, b, isEqual, meta);
113
+ }
114
+ // `isArray()` works on subclasses and is cross-realm, so we can again avoid
115
+ // the `toString.call()` cost unless necessary by just checking if either
116
+ // and then both are arrays.
117
+ var aArray = Array.isArray(a);
118
+ var bArray = Array.isArray(b);
119
+ if (aArray || bArray) {
120
+ return aArray === bArray && areArraysEqual(a, b, isEqual, meta);
121
+ }
122
+ // Since this is a custom object, use the classic `toString.call()` to get its
123
+ // type. This is reasonably performant in modern environments like v8 and
124
+ // SpiderMonkey, and allows for cross-realm comparison when other checks like
125
+ // `instanceof` do not.
126
+ var aTag = toString.call(a);
127
+ if (aTag !== toString.call(b)) {
128
+ return false;
129
+ }
130
+ if (aTag === DATE_TAG) {
131
+ // `getTime()` showed better results compared to alternatives like `valueOf()`
132
+ // or the unary `+` operator.
133
+ return areDatesEqual(a, b, isEqual, meta);
134
+ }
135
+ if (aTag === REG_EXP_TAG) {
136
+ return areRegExpsEqual(a, b, isEqual, meta);
137
+ }
138
+ if (aTag === MAP_TAG) {
139
+ return areMapsEqual(a, b, isEqual, meta);
140
+ }
141
+ if (aTag === SET_TAG) {
142
+ return areSetsEqual(a, b, isEqual, meta);
143
+ }
144
+ // If a simple object tag, then we can prioritize a simple object comparison because
145
+ // it is likely a custom class. If an arguments tag, it should be treated as a standard
146
+ // object.
147
+ if (aTag === OBJECT_TAG || aTag === ARGUMENTS_TAG) {
148
+ // The exception for value comparison is `Promise`-like contracts. These should be
149
+ // treated the same as standard `Promise` objects, which means strict equality.
150
+ return isPromiseLike(a) || isPromiseLike(b)
151
+ ? a === b
152
+ : areObjectsEqual(a, b, isEqual, meta);
153
+ }
154
+ // As the penultimate fallback, check if the values passed are primitive wrappers. This
155
+ // is very rare in modern JS, which is why it is deprioritized compared to all other object
156
+ // types.
157
+ if (aTag === BOOLEAN_TAG || aTag === NUMBER_TAG || aTag === STRING_TAG) {
158
+ return sameValueZeroEqual(a.valueOf(), b.valueOf());
159
+ }
160
+ // If not matching any tags that require a specific type of comparison, then use strict
161
+ // equality. This is for a few reasons:
162
+ // - For types that cannot be introspected (`Promise`, `WeakMap`, etc.), this is the only
163
+ // comparison that can be made.
164
+ // - For types that can be introspected, but rarely have requirements to be compared
165
+ // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common
166
+ // use-cases.
167
+ // - For types that can be introspected, but do not have an objective definition of what
168
+ // equality is (`Error`, etc.), the subjective decision was to be conservative.
169
+ // In all cases, these decisions should be reevaluated based on changes to the language and
170
+ // common development practices.
171
+ return a === b;
67
172
  }
68
- return getNewCacheFallback;
69
- })(HAS_WEAKSET_SUPPORT);
70
- /**
71
- * create a custom isEqual handler specific to circular objects
72
- *
73
- * @param [isEqual] the isEqual comparator to use instead of isDeepEqual
74
- * @returns the method to create the `isEqual` function
75
- */
76
- function createCircularEqualCreator(isEqual) {
77
- return function createCircularEqual(comparator) {
78
- var _comparator = isEqual || comparator;
79
- return function circularEqual(a, b, indexOrKeyA, indexOrKeyB, parentA, parentB, cache) {
80
- if (cache === void 0) { cache = getNewCache(); }
81
- var isCacheableA = !!a && typeof a === 'object';
82
- var isCacheableB = !!b && typeof b === 'object';
83
- if (isCacheableA || isCacheableB) {
84
- var hasA = isCacheableA && cache.has(a);
85
- var hasB = isCacheableB && cache.has(b);
86
- if (hasA || hasB) {
87
- return hasA && hasB;
88
- }
89
- if (isCacheableA) {
90
- cache.add(a);
91
- }
92
- if (isCacheableB) {
93
- cache.add(b);
94
- }
95
- }
96
- return _comparator(a, b, cache);
97
- };
98
- };
99
- }
173
+ return comparator;
174
+ }
175
+
100
176
  /**
101
- * are the arrays equal in value
102
- *
103
- * @param a the array to test
104
- * @param b the array to test against
105
- * @param isEqual the comparator to determine equality
106
- * @param meta the meta object to pass through
107
- * @returns are the arrays equal
177
+ * Whether the arrays are equal in value.
108
178
  */
109
179
  function areArraysEqual(a, b, isEqual, meta) {
110
180
  var index = a.length;
111
181
  if (b.length !== index) {
112
182
  return false;
113
183
  }
184
+ // Decrementing `while` showed faster results than either incrementing or
185
+ // decrementing `for` loop and than an incrementing `while` loop. Declarative
186
+ // methods like `some` / `every` were not used to avoid incurring the garbage
187
+ // cost of anonymous callbacks.
114
188
  while (index-- > 0) {
115
189
  if (!isEqual(a[index], b[index], index, index, a, b, meta)) {
116
190
  return false;
@@ -119,195 +193,223 @@ function areArraysEqual(a, b, isEqual, meta) {
119
193
  return true;
120
194
  }
121
195
  /**
122
- * are the maps equal in value
196
+ * Whether the arrays are equal in value, including circular references.
197
+ */
198
+ var areArraysEqualCircular = createIsCircular(areArraysEqual);
199
+
200
+ /**
201
+ * Whether the dates passed are equal in value.
123
202
  *
124
- * @param a the map to test
125
- * @param b the map to test against
126
- * @param isEqual the comparator to determine equality
127
- * @param meta the meta map to pass through
128
- * @returns are the maps equal
203
+ * @NOTE
204
+ * This is a standalone function instead of done inline in the comparator
205
+ * to allow for overrides.
206
+ */
207
+ function areDatesEqual(a, b) {
208
+ return sameValueZeroEqual(a.valueOf(), b.valueOf());
209
+ }
210
+
211
+ /**
212
+ * Whether the `Map`s are equal in value.
129
213
  */
130
214
  function areMapsEqual(a, b, isEqual, meta) {
131
215
  var isValueEqual = a.size === b.size;
132
- if (isValueEqual && a.size) {
133
- var matchedIndices_1 = {};
134
- var indexA_1 = 0;
135
- a.forEach(function (aValue, aKey) {
136
- if (isValueEqual) {
137
- var hasMatch_1 = false;
138
- var matchIndexB_1 = 0;
139
- b.forEach(function (bValue, bKey) {
140
- if (!hasMatch_1 && !matchedIndices_1[matchIndexB_1]) {
141
- hasMatch_1 =
142
- isEqual(aKey, bKey, indexA_1, matchIndexB_1, a, b, meta) &&
143
- isEqual(aValue, bValue, aKey, bKey, a, b, meta);
144
- if (hasMatch_1) {
145
- matchedIndices_1[matchIndexB_1] = true;
146
- }
147
- }
148
- matchIndexB_1++;
149
- });
150
- indexA_1++;
151
- isValueEqual = hasMatch_1;
216
+ if (!isValueEqual) {
217
+ return false;
218
+ }
219
+ if (!a.size) {
220
+ return true;
221
+ }
222
+ // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and
223
+ // the inability to control the performance of the resulting code. It also avoids excessive
224
+ // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,
225
+ // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the
226
+ // equality checks themselves.
227
+ var matchedIndices = {};
228
+ var indexA = 0;
229
+ a.forEach(function (aValue, aKey) {
230
+ if (!isValueEqual) {
231
+ return;
232
+ }
233
+ var hasMatch = false;
234
+ var matchIndexB = 0;
235
+ b.forEach(function (bValue, bKey) {
236
+ if (!hasMatch &&
237
+ !matchedIndices[matchIndexB] &&
238
+ (hasMatch =
239
+ isEqual(aKey, bKey, indexA, matchIndexB, a, b, meta) &&
240
+ isEqual(aValue, bValue, aKey, bKey, a, b, meta))) {
241
+ matchedIndices[matchIndexB] = true;
152
242
  }
243
+ matchIndexB++;
153
244
  });
154
- }
245
+ indexA++;
246
+ isValueEqual = hasMatch;
247
+ });
155
248
  return isValueEqual;
156
249
  }
250
+ /**
251
+ * Whether the `Map`s are equal in value, including circular references.
252
+ */
253
+ var areMapsEqualCircular = createIsCircular(areMapsEqual);
254
+
157
255
  var OWNER = '_owner';
158
- var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
256
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
159
257
  /**
160
- * are the objects equal in value
161
- *
162
- * @param a the object to test
163
- * @param b the object to test against
164
- * @param isEqual the comparator to determine equality
165
- * @param meta the meta object to pass through
166
- * @returns are the objects equal
258
+ * Whether the objects are equal in value.
167
259
  */
168
260
  function areObjectsEqual(a, b, isEqual, meta) {
169
- var keysA = keys(a);
261
+ var keysA = Object.keys(a);
170
262
  var index = keysA.length;
171
- if (keys(b).length !== index) {
263
+ if (Object.keys(b).length !== index) {
172
264
  return false;
173
265
  }
174
- if (index) {
175
- var key = void 0;
176
- while (index-- > 0) {
177
- key = keysA[index];
178
- if (key === OWNER) {
179
- var reactElementA = isReactElement(a);
180
- var reactElementB = isReactElement(b);
181
- if ((reactElementA || reactElementB) &&
182
- reactElementA !== reactElementB) {
183
- return false;
184
- }
185
- }
186
- if (!hasOwnProperty(b, key) ||
187
- !isEqual(a[key], b[key], key, key, a, b, meta)) {
266
+ var key;
267
+ // Decrementing `while` showed faster results than either incrementing or
268
+ // decrementing `for` loop and than an incrementing `while` loop. Declarative
269
+ // methods like `some` / `every` were not used to avoid incurring the garbage
270
+ // cost of anonymous callbacks.
271
+ while (index-- > 0) {
272
+ key = keysA[index];
273
+ if (key === OWNER) {
274
+ var reactElementA = !!a.$$typeof;
275
+ var reactElementB = !!b.$$typeof;
276
+ if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
188
277
  return false;
189
278
  }
190
279
  }
280
+ if (!hasOwnProperty.call(b, key) ||
281
+ !isEqual(a[key], b[key], key, key, a, b, meta)) {
282
+ return false;
283
+ }
191
284
  }
192
285
  return true;
193
286
  }
194
287
  /**
195
- * are the regExps equal in value
288
+ * Whether the objects are equal in value, including circular references.
289
+ */
290
+ var areObjectsEqualCircular = createIsCircular(areObjectsEqual);
291
+
292
+ /**
293
+ * Whether the regexps passed are equal in value.
196
294
  *
197
- * @param a the regExp to test
198
- * @param b the regExp to test agains
199
- * @returns are the regExps equal
295
+ * @NOTE
296
+ * This is a standalone function instead of done inline in the comparator
297
+ * to allow for overrides. An example of this would be supporting a
298
+ * pre-ES2015 environment where the `flags` property is not available.
200
299
  */
201
300
  function areRegExpsEqual(a, b) {
202
- return (a.source === b.source &&
203
- a.global === b.global &&
204
- a.ignoreCase === b.ignoreCase &&
205
- a.multiline === b.multiline &&
206
- a.unicode === b.unicode &&
207
- a.sticky === b.sticky &&
208
- a.lastIndex === b.lastIndex);
209
- }
301
+ return a.source === b.source && a.flags === b.flags;
302
+ }
303
+
210
304
  /**
211
- * are the sets equal in value
212
- *
213
- * @param a the set to test
214
- * @param b the set to test against
215
- * @param isEqual the comparator to determine equality
216
- * @param meta the meta set to pass through
217
- * @returns are the sets equal
305
+ * Whether the `Set`s are equal in value.
218
306
  */
219
307
  function areSetsEqual(a, b, isEqual, meta) {
220
308
  var isValueEqual = a.size === b.size;
221
- if (isValueEqual && a.size) {
222
- var matchedIndices_2 = {};
223
- a.forEach(function (aValue, aKey) {
224
- if (isValueEqual) {
225
- var hasMatch_2 = false;
226
- var matchIndex_1 = 0;
227
- b.forEach(function (bValue, bKey) {
228
- if (!hasMatch_2 && !matchedIndices_2[matchIndex_1]) {
229
- hasMatch_2 = isEqual(aValue, bValue, aKey, bKey, a, b, meta);
230
- if (hasMatch_2) {
231
- matchedIndices_2[matchIndex_1] = true;
232
- }
233
- }
234
- matchIndex_1++;
235
- });
236
- isValueEqual = hasMatch_2;
309
+ if (!isValueEqual) {
310
+ return false;
311
+ }
312
+ if (!a.size) {
313
+ return true;
314
+ }
315
+ // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and
316
+ // the inability to control the performance of the resulting code. It also avoids excessive
317
+ // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,
318
+ // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the
319
+ // equality checks themselves.
320
+ var matchedIndices = {};
321
+ a.forEach(function (aValue, aKey) {
322
+ if (!isValueEqual) {
323
+ return;
324
+ }
325
+ var hasMatch = false;
326
+ var matchIndex = 0;
327
+ b.forEach(function (bValue, bKey) {
328
+ if (!hasMatch &&
329
+ !matchedIndices[matchIndex] &&
330
+ (hasMatch = isEqual(aValue, bValue, aKey, bKey, a, b, meta))) {
331
+ matchedIndices[matchIndex] = true;
237
332
  }
333
+ matchIndex++;
238
334
  });
239
- }
335
+ isValueEqual = hasMatch;
336
+ });
240
337
  return isValueEqual;
241
- }
338
+ }
339
+ /**
340
+ * Whether the `Set`s are equal in value, including circular references.
341
+ */
342
+ var areSetsEqualCircular = createIsCircular(areSetsEqual);
242
343
 
243
- var HAS_MAP_SUPPORT = typeof Map === 'function';
244
- var HAS_SET_SUPPORT = typeof Set === 'function';
245
- function createComparator(createIsEqual) {
246
- var isEqual =
247
- /* eslint-disable no-use-before-define */
248
- typeof createIsEqual === 'function'
249
- ? createIsEqual(comparator)
250
- : function (a, b, indexOrKeyA, indexOrKeyB, parentA, parentB, meta) { return comparator(a, b, meta); };
251
- /* eslint-enable */
252
- /**
253
- * compare the value of the two objects and return true if they are equivalent in values
254
- *
255
- * @param a the value to test against
256
- * @param b the value to test
257
- * @param [meta] an optional meta object that is passed through to all equality test calls
258
- * @returns are a and b equivalent in value
259
- */
260
- function comparator(a, b, meta) {
261
- if (a === b) {
262
- return true;
263
- }
264
- if (a && b && typeof a === 'object' && typeof b === 'object') {
265
- if (isPlainObject(a) && isPlainObject(b)) {
266
- return areObjectsEqual(a, b, isEqual, meta);
267
- }
268
- var aShape = Array.isArray(a);
269
- var bShape = Array.isArray(b);
270
- if (aShape || bShape) {
271
- return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
272
- }
273
- aShape = a instanceof Date;
274
- bShape = b instanceof Date;
275
- if (aShape || bShape) {
276
- return (aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime()));
277
- }
278
- aShape = a instanceof RegExp;
279
- bShape = b instanceof RegExp;
280
- if (aShape || bShape) {
281
- return aShape === bShape && areRegExpsEqual(a, b);
282
- }
283
- if (isPromiseLike(a) || isPromiseLike(b)) {
284
- return a === b;
285
- }
286
- if (HAS_MAP_SUPPORT) {
287
- aShape = a instanceof Map;
288
- bShape = b instanceof Map;
289
- if (aShape || bShape) {
290
- return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
291
- }
292
- }
293
- if (HAS_SET_SUPPORT) {
294
- aShape = a instanceof Set;
295
- bShape = b instanceof Set;
296
- if (aShape || bShape) {
297
- return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
298
- }
299
- }
300
- return areObjectsEqual(a, b, isEqual, meta);
301
- }
302
- return a !== a && b !== b;
303
- }
304
- return comparator;
344
+ var DEFAULT_CONFIG = Object.freeze({
345
+ areArraysEqual: areArraysEqual,
346
+ areDatesEqual: areDatesEqual,
347
+ areMapsEqual: areMapsEqual,
348
+ areObjectsEqual: areObjectsEqual,
349
+ areRegExpsEqual: areRegExpsEqual,
350
+ areSetsEqual: areSetsEqual,
351
+ createIsNestedEqual: createDefaultIsNestedEqual,
352
+ });
353
+ var DEFAULT_CIRCULAR_CONFIG = Object.freeze(merge(DEFAULT_CONFIG, {
354
+ areArraysEqual: areArraysEqualCircular,
355
+ areMapsEqual: areMapsEqualCircular,
356
+ areObjectsEqual: areObjectsEqualCircular,
357
+ areSetsEqual: areSetsEqualCircular,
358
+ }));
359
+ var isDeepEqual = createComparator(DEFAULT_CONFIG);
360
+ /**
361
+ * Whether the items passed are deeply-equal in value.
362
+ */
363
+ function deepEqual(a, b) {
364
+ return isDeepEqual(a, b, undefined);
365
+ }
366
+ var isShallowEqual = createComparator(merge(DEFAULT_CONFIG, { createIsNestedEqual: function () { return sameValueZeroEqual; } }));
367
+ /**
368
+ * Whether the items passed are shallowly-equal in value.
369
+ */
370
+ function shallowEqual(a, b) {
371
+ return isShallowEqual(a, b, undefined);
372
+ }
373
+ var isCircularDeepEqual = createComparator(DEFAULT_CIRCULAR_CONFIG);
374
+ /**
375
+ * Whether the items passed are deeply-equal in value, including circular references.
376
+ */
377
+ function circularDeepEqual(a, b) {
378
+ return isCircularDeepEqual(a, b, new WeakMap());
379
+ }
380
+ var isCircularShallowEqual = createComparator(merge(DEFAULT_CIRCULAR_CONFIG, {
381
+ createIsNestedEqual: function () { return sameValueZeroEqual; },
382
+ }));
383
+ /**
384
+ * Whether the items passed are shallowly-equal in value, including circular references.
385
+ */
386
+ function circularShallowEqual(a, b) {
387
+ return isCircularShallowEqual(a, b, new WeakMap());
388
+ }
389
+ /**
390
+ * Create a custom equality comparison method.
391
+ *
392
+ * This can be done to create very targeted comparisons in extreme hot-path scenarios
393
+ * where the standard methods are not performant enough, but can also be used to provide
394
+ * support for legacy environments that do not support expected features like
395
+ * `RegExp.prototype.flags` out of the box.
396
+ */
397
+ function createCustomEqual(getComparatorOptions) {
398
+ return createComparator(merge(DEFAULT_CONFIG, getComparatorOptions(DEFAULT_CONFIG)));
399
+ }
400
+ /**
401
+ * Create a custom equality comparison method that handles circular references. This is very
402
+ * similar to `createCustomEqual`, with the only difference being that `meta` expects to be
403
+ * populated with a `WeakMap`-like contract.
404
+ *
405
+ * This can be done to create very targeted comparisons in extreme hot-path scenarios
406
+ * where the standard methods are not performant enough, but can also be used to provide
407
+ * support for legacy environments that do not support expected features like
408
+ * `WeakMap` out of the box.
409
+ */
410
+ function createCustomCircularEqual(getComparatorOptions) {
411
+ return createComparator(merge(DEFAULT_CIRCULAR_CONFIG, getComparatorOptions(DEFAULT_CIRCULAR_CONFIG)));
305
412
  }
306
413
 
307
- var deepEqual = createComparator();
308
- var shallowEqual = createComparator(function () { return sameValueZeroEqual; });
309
- var circularDeepEqual = createComparator(createCircularEqualCreator());
310
- var circularShallowEqual = createComparator(createCircularEqualCreator(sameValueZeroEqual));
311
-
312
- export { circularDeepEqual, circularShallowEqual, createComparator as createCustomEqual, deepEqual, sameValueZeroEqual, shallowEqual };
414
+ export { circularDeepEqual, circularShallowEqual, createCustomCircularEqual, createCustomEqual, deepEqual, sameValueZeroEqual, shallowEqual };
313
415
  //# sourceMappingURL=fast-equals.esm.js.map