fast-equals 5.0.0-beta.3 → 5.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/README.md +3 -1
- package/dist/cjs/index.cjs +31 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/types/comparator.d.ts +1 -1
- package/dist/cjs/types/equals.d.ts +2 -1
- package/dist/cjs/types/internalTypes.d.ts +2 -0
- package/dist/cjs/types/utils.d.ts +1 -0
- package/dist/esm/index.mjs +31 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/types/comparator.d.ts +1 -1
- package/dist/esm/types/equals.d.ts +2 -1
- package/dist/esm/types/internalTypes.d.ts +2 -0
- package/dist/esm/types/utils.d.ts +1 -0
- package/dist/min/index.js +1 -1
- package/dist/min/types/comparator.d.ts +1 -1
- package/dist/min/types/equals.d.ts +2 -1
- package/dist/min/types/internalTypes.d.ts +2 -0
- package/dist/min/types/utils.d.ts +1 -0
- package/dist/umd/index.js +31 -1
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/types/comparator.d.ts +1 -1
- package/dist/umd/types/equals.d.ts +2 -1
- package/dist/umd/types/internalTypes.d.ts +2 -0
- package/dist/umd/types/utils.d.ts +1 -0
- package/package.json +4 -1
- package/src/comparator.ts +22 -3
- package/src/equals.ts +17 -1
- package/src/internalTypes.ts +12 -0
- package/src/utils.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -31,11 +31,15 @@ The following new comparators are available:
|
|
|
31
31
|
|
|
32
32
|
This will perform the same comparisons as their non-strict counterparts, but will verify additional properties (non-enumerable properties on objects, keyed objects on `Array` / `Map` / `Set`) and that the descriptors for the properties align.
|
|
33
33
|
|
|
34
|
+
#### `TypedArray` support
|
|
35
|
+
|
|
36
|
+
Support for comparing all typed array values is now supported, and you can provide a custom comparator via the new `areTypedArraysEqual` option in the `createCustomEqual` configuration.
|
|
37
|
+
|
|
34
38
|
#### Better build system resolution
|
|
35
39
|
|
|
36
40
|
The library now leverages the `exports` property in the `package.json` to provide builds specific to your method of consumption (ESM / CommonJS / UMD). There is still a minified UMD version available if you want to use it instead.
|
|
37
41
|
|
|
38
|
-
#### `arePrimitiveWrappersEqual` added to `createCustomEqual` configuration
|
|
42
|
+
#### `arePrimitiveWrappersEqual` option added to `createCustomEqual` configuration
|
|
39
43
|
|
|
40
44
|
If you want a custom comparator for primitive wrappers (`new Boolean()` / `new Number()` / `new String()`) it is now available.
|
|
41
45
|
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<img src="https://img.shields.io/badge/coverage-100%25-brightgreen.svg"/>
|
|
5
5
|
<img src="https://img.shields.io/badge/license-MIT-blue.svg"/>
|
|
6
6
|
|
|
7
|
-
Perform [blazing fast](#benchmarks) equality comparisons (either deep or shallow) on two objects passed. It has no dependencies, and is ~1.
|
|
7
|
+
Perform [blazing fast](#benchmarks) equality comparisons (either deep or shallow) on two objects passed. It has no dependencies, and is ~1.75kB when minified and gzipped.
|
|
8
8
|
|
|
9
9
|
Unlike most equality validation libraries, the following types are handled out-of-the-box:
|
|
10
10
|
|
|
@@ -162,6 +162,7 @@ console.log(circularShallowEqual(array, [array])); // false
|
|
|
162
162
|
|
|
163
163
|
Performs the same comparison as `deepEqual` but performs a strict comparison of the objects. In this includes:
|
|
164
164
|
|
|
165
|
+
- Checking constructors match
|
|
165
166
|
- Checking non-enumerable properties in object comparisons
|
|
166
167
|
- Checking full descriptor of properties on the object to match
|
|
167
168
|
- Checking non-index properties on arrays
|
|
@@ -296,6 +297,7 @@ interface CreateComparatorCreatorOptions<Meta> {
|
|
|
296
297
|
>;
|
|
297
298
|
areRegExpsEqual: TypeEqualityComparator<RegExp, Meta>;
|
|
298
299
|
areSetsEqual: TypeEqualityComparator<Set<any>, Meta>;
|
|
300
|
+
areTypedArraysEqual: TypeEqualityComparatory<TypedArray, Meta>;
|
|
299
301
|
}
|
|
300
302
|
|
|
301
303
|
interface CustomEqualCreatorOptions<Meta> {
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
4
4
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
5
|
+
var SUPPORTS_ARRAY_BUFFER = typeof ArrayBuffer === 'function' && Boolean(ArrayBuffer.isView);
|
|
5
6
|
/**
|
|
6
7
|
* Combine two comparators into a single comparators.
|
|
7
8
|
*/
|
|
@@ -57,6 +58,9 @@ var hasOwn = Object.hasOwn ||
|
|
|
57
58
|
(function (object, property) {
|
|
58
59
|
return hasOwnProperty.call(object, property);
|
|
59
60
|
});
|
|
61
|
+
function isArrayBuffer(value) {
|
|
62
|
+
return SUPPORTS_ARRAY_BUFFER && ArrayBuffer.isView(value);
|
|
63
|
+
}
|
|
60
64
|
/**
|
|
61
65
|
* Whether the values passed are strictly equal or both NaN.
|
|
62
66
|
*/
|
|
@@ -235,6 +239,18 @@ function areSetsEqual(a, b, state) {
|
|
|
235
239
|
}
|
|
236
240
|
return isValueEqual;
|
|
237
241
|
}
|
|
242
|
+
function areTypedArraysEqual(a, b) {
|
|
243
|
+
var index = a.length;
|
|
244
|
+
if (b.length !== index) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
while (index-- > 0) {
|
|
248
|
+
if (a[index] !== b[index]) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
238
254
|
|
|
239
255
|
var ARGUMENTS_TAG = '[object Arguments]';
|
|
240
256
|
var BOOLEAN_TAG = '[object Boolean]';
|
|
@@ -252,7 +268,7 @@ var getTag = Object.prototype.toString.call.bind(Object.prototype.toString);
|
|
|
252
268
|
* Create a comparator method based on the type-specific equality comparators passed.
|
|
253
269
|
*/
|
|
254
270
|
function createComparator(_a) {
|
|
255
|
-
var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areMapsEqual = _a.areMapsEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual;
|
|
271
|
+
var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areMapsEqual = _a.areMapsEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, areTypedArraysEqual = _a.areTypedArraysEqual;
|
|
256
272
|
/**
|
|
257
273
|
* compare the value of the two objects and return true if they are equivalent in values
|
|
258
274
|
*/
|
|
@@ -282,6 +298,12 @@ function createComparator(_a) {
|
|
|
282
298
|
if (a.constructor === Object && b.constructor === Object) {
|
|
283
299
|
return areObjectsEqual(a, b, state);
|
|
284
300
|
}
|
|
301
|
+
// In strict mode, constructors should match. We placed this after the plain object check
|
|
302
|
+
// because the constructors must match to meet plain object requirements (must both be `Object`
|
|
303
|
+
// in the given Realm), so it slightly improves performance on a very common use-case.
|
|
304
|
+
if (state.strict && a.constructor !== b.constructor) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
285
307
|
// `isArray()` works on subclasses and is cross-realm, so we can again avoid
|
|
286
308
|
// the `toString.call()` cost unless necessary by just checking if either
|
|
287
309
|
// and then both are arrays.
|
|
@@ -290,6 +312,11 @@ function createComparator(_a) {
|
|
|
290
312
|
if (aArray || bArray) {
|
|
291
313
|
return aArray === bArray && areArraysEqual(a, b, state);
|
|
292
314
|
}
|
|
315
|
+
aArray = isArrayBuffer(a);
|
|
316
|
+
bArray = isArrayBuffer(b);
|
|
317
|
+
if (aArray || bArray) {
|
|
318
|
+
return aArray === bArray && areTypedArraysEqual(a, b, state);
|
|
319
|
+
}
|
|
293
320
|
// Since this is a custom object, use the classic `toString.call()` to get its
|
|
294
321
|
// type. This is reasonably performant in modern environments like v8 and
|
|
295
322
|
// SpiderMonkey, and allows for cross-realm comparison when other checks like
|
|
@@ -365,6 +392,9 @@ function createComparatorConfig(_a) {
|
|
|
365
392
|
areSetsEqual: strict
|
|
366
393
|
? combineComparators(areSetsEqual, areObjectsEqualStrict)
|
|
367
394
|
: areSetsEqual,
|
|
395
|
+
areTypedArraysEqual: strict
|
|
396
|
+
? combineComparators(areTypedArraysEqual, areObjectsEqualStrict)
|
|
397
|
+
: areTypedArraysEqual,
|
|
368
398
|
};
|
|
369
399
|
if (createCustomConfig) {
|
|
370
400
|
config = assign({}, config, createCustomConfig(config));
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/utils.ts","../../src/equals.ts","../../src/comparator.ts","../../src/index.ts"],"sourcesContent":["import {\n AnyEqualityComparator,\n BaseCircular,\n CircularState,\n Dictionary,\n EqualityComparator,\n InternalEqualityComparator,\n State,\n TypeEqualityComparator,\n} from './internalTypes';\n\nconst { getOwnPropertyNames, getOwnPropertySymbols } = Object;\nconst { hasOwnProperty } = Object.prototype;\n\n/**\n * Combine two comparators into a single comparators.\n */\nexport function combineComparators<Meta>(\n comparatorA: AnyEqualityComparator<Meta>,\n comparatorB: AnyEqualityComparator<Meta>,\n) {\n return function isEqual<A, B>(a: A, b: B, state: State<Meta>) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nexport function createInternalComparator<Meta>(\n compare: EqualityComparator<Meta>,\n): InternalEqualityComparator<Meta> {\n return function (\n a: any,\n b: any,\n _indexOrKeyA: any,\n _indexOrKeyB: any,\n _parentA: any,\n _parentB: any,\n state: State<Meta>,\n ) {\n return compare(a, b, state);\n };\n}\n\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nexport function createIsCircular<\n AreItemsEqual extends TypeEqualityComparator<any, any>,\n>(areItemsEqual: AreItemsEqual): AreItemsEqual {\n return function isCircular(\n a: any,\n b: any,\n state: CircularState<BaseCircular>,\n ) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n\n const { cache } = state;\n\n const cachedA = cache.get(a);\n const cachedB = cache.get(b);\n\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n\n cache.set(a, b);\n cache.set(b, a);\n\n const result = areItemsEqual(a, b, state);\n\n cache.delete(a);\n cache.delete(b);\n\n return result;\n } as AreItemsEqual;\n}\n\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nexport function getStrictProperties(\n object: Dictionary,\n): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object),\n );\n}\n\n/**\n * Whether the object contains the property passed as an own property.\n */\nexport const hasOwn =\n Object.hasOwn ||\n ((object: Dictionary, property: number | string | symbol) =>\n hasOwnProperty.call(object, property));\n\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nexport function sameValueZeroEqual(a: any, b: any): boolean {\n return a || b ? a === b : a === b || (a !== a && b !== b);\n}\n","import { getStrictProperties, hasOwn, sameValueZeroEqual } from './utils';\nimport type { Dictionary, State } from './internalTypes';\n\nconst OWNER = '_owner';\n\nconst { getOwnPropertyDescriptor, keys } = Object;\n\n/**\n * Whether the arrays are equal in value.\n */\nexport function areArraysEqual(a: any[], b: any[], state: State<any>) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the dates passed are equal in value.\n */\nexport function areDatesEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n\n/**\n * Whether the `Map`s are equal in value.\n */\nexport function areMapsEqual(\n a: Map<any, any>,\n b: Map<any, any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n let indexA = 0;\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndexB = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndexB] &&\n (hasMatch =\n state.equals(aKey, bKey, indexA, matchIndexB, a, b, state) &&\n state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndexB] = true;\n }\n\n matchIndexB++;\n });\n\n indexA++;\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\n/**\n * Whether the objects are equal in value.\n */\nexport function areObjectsEqual(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = keys(a);\n\n let index = properties.length;\n\n if (keys(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (\n !hasOwn(b, property) ||\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nexport function areObjectsEqualStrict(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = getStrictProperties(a);\n\n let index = properties.length;\n\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n let descriptorA: ReturnType<typeof getOwnPropertyDescriptor>;\n let descriptorB: ReturnType<typeof getOwnPropertyDescriptor>;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (!hasOwn(b, property)) {\n return false;\n }\n\n if (\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n\n if (\n (descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nexport function arePrimitiveWrappersEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n\n/**\n * Whether the regexps passed are equal in value.\n */\nexport function areRegExpsEqual(a: RegExp, b: RegExp): boolean {\n return a.source === b.source && a.flags === b.flags;\n}\n\n/**\n * Whether the `Set`s are equal in value.\n */\nexport function areSetsEqual(\n a: Set<any>,\n b: Set<any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndex = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndex] &&\n (hasMatch = state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndex] = true;\n }\n\n matchIndex++;\n });\n\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n","import {\n areArraysEqual as areArraysEqualDefault,\n areDatesEqual as areDatesEqualDefault,\n areMapsEqual as areMapsEqualDefault,\n areObjectsEqual as areObjectsEqualDefault,\n areObjectsEqualStrict as areObjectsEqualStrictDefault,\n arePrimitiveWrappersEqual as arePrimitiveWrappersEqualDefault,\n areRegExpsEqual as areRegExpsEqualDefault,\n areSetsEqual as areSetsEqualDefault,\n} from './equals';\nimport { combineComparators, createIsCircular } from './utils';\nimport type {\n ComparatorConfig,\n CustomEqualCreatorOptions,\n EqualityComparator,\n State,\n} from './internalTypes';\n\nconst ARGUMENTS_TAG = '[object Arguments]';\nconst BOOLEAN_TAG = '[object Boolean]';\nconst DATE_TAG = '[object Date]';\nconst MAP_TAG = '[object Map]';\nconst NUMBER_TAG = '[object Number]';\nconst OBJECT_TAG = '[object Object]';\nconst REG_EXP_TAG = '[object RegExp]';\nconst SET_TAG = '[object Set]';\nconst STRING_TAG = '[object String]';\n\nconst { isArray } = Array;\nconst { assign } = Object;\nconst getTag = Object.prototype.toString.call.bind(\n Object.prototype.toString,\n) as (a: object) => string;\n\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nexport function createComparator<Meta>({\n areArraysEqual,\n areDatesEqual,\n areMapsEqual,\n areObjectsEqual,\n arePrimitiveWrappersEqual,\n areRegExpsEqual,\n areSetsEqual,\n}: ComparatorConfig<Meta>): EqualityComparator<Meta> {\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a: any, b: any, state: State<Meta>): boolean {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n\n // If the items are not non-nullish objects, then the only possibility\n // of them being equal but not strictly is if they are both `NaN`. Since\n // `NaN` is uniquely not equal to itself, we can use self-comparison of\n // both objects, which is faster than `isNaN()`.\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return a !== a && b !== b;\n }\n\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid the `toString.call()` cost unless necessary.\n if (a.constructor === Object && b.constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n\n // `isArray()` works on subclasses and is cross-realm, so we can again avoid\n // the `toString.call()` cost unless necessary by just checking if either\n // and then both are arrays.\n const aArray = isArray(a);\n const bArray = isArray(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areArraysEqual(a, b, state);\n }\n\n // Since this is a custom object, use the classic `toString.call()` to get its\n // type. This is reasonably performant in modern environments like v8 and\n // SpiderMonkey, and allows for cross-realm comparison when other checks like\n // `instanceof` do not.\n const tag = getTag(a);\n\n if (tag !== getTag(b)) {\n return false;\n }\n\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n\n // If a simple object tag, then we can prioritize a simple object comparison because\n // it is likely a custom class.\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is `Promise`-like contracts. These should be\n // treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (\n typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state)\n );\n }\n\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n\n/**\n * Create the configuration object used for building comparators.\n */\nexport function createComparatorConfig<Meta>({\n circular,\n createCustomConfig,\n strict,\n}: CustomEqualCreatorOptions<Meta>): ComparatorConfig<Meta> {\n let config = {\n areArraysEqual: strict\n ? areObjectsEqualStrictDefault\n : areArraysEqualDefault,\n areDatesEqual: areDatesEqualDefault,\n areMapsEqual: strict\n ? combineComparators(areMapsEqualDefault, areObjectsEqualStrictDefault)\n : areMapsEqualDefault,\n areObjectsEqual: strict\n ? areObjectsEqualStrictDefault\n : areObjectsEqualDefault,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqualDefault,\n areRegExpsEqual: areRegExpsEqualDefault,\n areSetsEqual: strict\n ? combineComparators(areSetsEqualDefault, areObjectsEqualStrictDefault)\n : areSetsEqualDefault,\n };\n\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n\n if (circular) {\n const areArraysEqual = createIsCircular(config.areArraysEqual);\n const areMapsEqual = createIsCircular(config.areMapsEqual);\n const areObjectsEqual = createIsCircular(config.areObjectsEqual);\n const areSetsEqual = createIsCircular(config.areSetsEqual);\n\n config = assign({}, config, {\n areArraysEqual,\n areMapsEqual,\n areObjectsEqual,\n areSetsEqual,\n });\n }\n\n return config;\n}\n","import { createComparator, createComparatorConfig } from './comparator';\nimport type {\n CircularState,\n CustomEqualCreatorOptions,\n DefaultState,\n} from './internalTypes';\nimport { createInternalComparator, sameValueZeroEqual } from './utils';\n\nexport { sameValueZeroEqual };\nexport * from './internalTypes';\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nexport const deepEqual = createCustomEqual();\n\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nexport const strictDeepEqual = createCustomEqual({ strict: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nexport const circularDeepEqual = createCustomEqual({ circular: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nexport const shallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nexport const strictShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nexport const circularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n strict: true,\n});\n\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nexport function createCustomEqual<Meta>(\n options: CustomEqualCreatorOptions<Meta> = {},\n) {\n const {\n circular,\n comparator,\n createInternalComparator: createCustomInternalComparator,\n createState,\n strict: baseStrict = false,\n } = options;\n\n const config = createComparatorConfig<Meta>(options);\n const isEqualCustom = createComparator(config);\n const isEqualCustomComparator =\n comparator ||\n (createCustomInternalComparator\n ? createCustomInternalComparator(isEqualCustom)\n : createInternalComparator(isEqualCustom));\n\n if (createState) {\n return function isEqual<A, B>(\n a: A,\n b: B,\n metaOverride?: Meta | undefined,\n ): boolean {\n const {\n cache = circular ? new WeakMap() : undefined,\n equals = isEqualCustomComparator,\n meta,\n strict = baseStrict,\n } = createState!(isEqualCustom);\n\n return isEqualCustom(a, b, {\n cache,\n equals,\n meta: metaOverride !== undefined ? metaOverride : meta,\n strict,\n } as CircularState<Meta>);\n };\n }\n\n if (circular) {\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, {\n cache: new WeakMap(),\n equals: isEqualCustomComparator,\n meta: undefined as Meta,\n strict: baseStrict,\n } as CircularState<Meta>);\n };\n }\n\n const state = Object.freeze({\n cache: undefined,\n equals: isEqualCustomComparator,\n meta: undefined,\n strict: baseStrict,\n });\n\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, state as DefaultState<Meta>);\n };\n}\n"],"names":["areObjectsEqualStrictDefault","areArraysEqualDefault","areDatesEqualDefault","areMapsEqualDefault","areObjectsEqualDefault","arePrimitiveWrappersEqualDefault","areRegExpsEqualDefault","areSetsEqualDefault","areArraysEqual","areMapsEqual","areObjectsEqual","areSetsEqual"],"mappings":";;AAWQ,IAAA,mBAAmB,GAA4B,MAAM,CAAA,mBAAlC,EAAE,qBAAqB,GAAK,MAAM,CAAA,qBAAX,CAAY;AACtD,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAE5C;;AAEG;AACa,SAAA,kBAAkB,CAChC,WAAwC,EACxC,WAAwC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,MAAM,CAAC,MAAM,CAAC;AAC1B,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,MAAM,EAAE,uBAAuB;AAC/B,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,MAAM,EAAE,UAAU;AACnB,KAAA,CAAC,CAAC;AAEH,IAAA,OAAO,SAAS,MAAM,CAAO,CAAI,EAAE,CAAI,EAAA;QACrC,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,KAA2B,CAAC,CAAC;AAC1D,KAAC,CAAC;AACJ;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/utils.ts","../../src/equals.ts","../../src/comparator.ts","../../src/index.ts"],"sourcesContent":["import {\n AnyEqualityComparator,\n BaseCircular,\n CircularState,\n Dictionary,\n EqualityComparator,\n InternalEqualityComparator,\n State,\n TypeEqualityComparator,\n} from './internalTypes';\n\nconst { getOwnPropertyNames, getOwnPropertySymbols } = Object;\nconst { hasOwnProperty } = Object.prototype;\n\nconst SUPPORTS_ARRAY_BUFFER =\n typeof ArrayBuffer === 'function' && Boolean(ArrayBuffer.isView);\n\n/**\n * Combine two comparators into a single comparators.\n */\nexport function combineComparators<Meta>(\n comparatorA: AnyEqualityComparator<Meta>,\n comparatorB: AnyEqualityComparator<Meta>,\n) {\n return function isEqual<A, B>(a: A, b: B, state: State<Meta>) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nexport function createInternalComparator<Meta>(\n compare: EqualityComparator<Meta>,\n): InternalEqualityComparator<Meta> {\n return function (\n a: any,\n b: any,\n _indexOrKeyA: any,\n _indexOrKeyB: any,\n _parentA: any,\n _parentB: any,\n state: State<Meta>,\n ) {\n return compare(a, b, state);\n };\n}\n\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nexport function createIsCircular<\n AreItemsEqual extends TypeEqualityComparator<any, any>,\n>(areItemsEqual: AreItemsEqual): AreItemsEqual {\n return function isCircular(\n a: any,\n b: any,\n state: CircularState<BaseCircular>,\n ) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n\n const { cache } = state;\n\n const cachedA = cache.get(a);\n const cachedB = cache.get(b);\n\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n\n cache.set(a, b);\n cache.set(b, a);\n\n const result = areItemsEqual(a, b, state);\n\n cache.delete(a);\n cache.delete(b);\n\n return result;\n } as AreItemsEqual;\n}\n\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nexport function getStrictProperties(\n object: Dictionary,\n): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object),\n );\n}\n\n/**\n * Whether the object contains the property passed as an own property.\n */\nexport const hasOwn =\n Object.hasOwn ||\n ((object: Dictionary, property: number | string | symbol) =>\n hasOwnProperty.call(object, property));\n\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return SUPPORTS_ARRAY_BUFFER && ArrayBuffer.isView(value);\n}\n\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nexport function sameValueZeroEqual(a: any, b: any): boolean {\n return a || b ? a === b : a === b || (a !== a && b !== b);\n}\n","import { getStrictProperties, hasOwn, sameValueZeroEqual } from './utils';\nimport type { Dictionary, State, TypedArray } from './internalTypes';\n\nconst OWNER = '_owner';\n\nconst { getOwnPropertyDescriptor, keys } = Object;\n\n/**\n * Whether the arrays are equal in value.\n */\nexport function areArraysEqual(a: any[], b: any[], state: State<any>) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the dates passed are equal in value.\n */\nexport function areDatesEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n\n/**\n * Whether the `Map`s are equal in value.\n */\nexport function areMapsEqual(\n a: Map<any, any>,\n b: Map<any, any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n let indexA = 0;\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndexB = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndexB] &&\n (hasMatch =\n state.equals(aKey, bKey, indexA, matchIndexB, a, b, state) &&\n state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndexB] = true;\n }\n\n matchIndexB++;\n });\n\n indexA++;\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\n/**\n * Whether the objects are equal in value.\n */\nexport function areObjectsEqual(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = keys(a);\n\n let index = properties.length;\n\n if (keys(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (\n !hasOwn(b, property) ||\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nexport function areObjectsEqualStrict(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = getStrictProperties(a);\n\n let index = properties.length;\n\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n let descriptorA: ReturnType<typeof getOwnPropertyDescriptor>;\n let descriptorB: ReturnType<typeof getOwnPropertyDescriptor>;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (!hasOwn(b, property)) {\n return false;\n }\n\n if (\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n\n if (\n (descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nexport function arePrimitiveWrappersEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n\n/**\n * Whether the regexps passed are equal in value.\n */\nexport function areRegExpsEqual(a: RegExp, b: RegExp): boolean {\n return a.source === b.source && a.flags === b.flags;\n}\n\n/**\n * Whether the `Set`s are equal in value.\n */\nexport function areSetsEqual(\n a: Set<any>,\n b: Set<any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndex = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndex] &&\n (hasMatch = state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndex] = true;\n }\n\n matchIndex++;\n });\n\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\nexport function areTypedArraysEqual(a: TypedArray, b: TypedArray) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (a[index] !== b[index]) {\n return false;\n }\n }\n\n return true;\n}\n","import {\n areArraysEqual as areArraysEqualDefault,\n areDatesEqual as areDatesEqualDefault,\n areMapsEqual as areMapsEqualDefault,\n areObjectsEqual as areObjectsEqualDefault,\n areObjectsEqualStrict as areObjectsEqualStrictDefault,\n arePrimitiveWrappersEqual as arePrimitiveWrappersEqualDefault,\n areRegExpsEqual as areRegExpsEqualDefault,\n areSetsEqual as areSetsEqualDefault,\n areTypedArraysEqual,\n} from './equals';\nimport { combineComparators, createIsCircular, isArrayBuffer } from './utils';\nimport type {\n ComparatorConfig,\n CustomEqualCreatorOptions,\n EqualityComparator,\n State,\n} from './internalTypes';\n\nconst ARGUMENTS_TAG = '[object Arguments]';\nconst BOOLEAN_TAG = '[object Boolean]';\nconst DATE_TAG = '[object Date]';\nconst MAP_TAG = '[object Map]';\nconst NUMBER_TAG = '[object Number]';\nconst OBJECT_TAG = '[object Object]';\nconst REG_EXP_TAG = '[object RegExp]';\nconst SET_TAG = '[object Set]';\nconst STRING_TAG = '[object String]';\n\nconst { isArray } = Array;\nconst { assign } = Object;\nconst getTag = Object.prototype.toString.call.bind(\n Object.prototype.toString,\n) as (a: object) => string;\n\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nexport function createComparator<Meta>({\n areArraysEqual,\n areDatesEqual,\n areMapsEqual,\n areObjectsEqual,\n arePrimitiveWrappersEqual,\n areRegExpsEqual,\n areSetsEqual,\n areTypedArraysEqual,\n}: ComparatorConfig<Meta>): EqualityComparator<Meta> {\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a: any, b: any, state: State<Meta>): boolean {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n\n // If the items are not non-nullish objects, then the only possibility\n // of them being equal but not strictly is if they are both `NaN`. Since\n // `NaN` is uniquely not equal to itself, we can use self-comparison of\n // both objects, which is faster than `isNaN()`.\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return a !== a && b !== b;\n }\n\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid the `toString.call()` cost unless necessary.\n if (a.constructor === Object && b.constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n\n // In strict mode, constructors should match. We placed this after the plain object check\n // because the constructors must match to meet plain object requirements (must both be `Object`\n // in the given Realm), so it slightly improves performance on a very common use-case.\n if (state.strict && a.constructor !== b.constructor) {\n return false;\n }\n\n // `isArray()` works on subclasses and is cross-realm, so we can again avoid\n // the `toString.call()` cost unless necessary by just checking if either\n // and then both are arrays.\n let aArray = isArray(a);\n let bArray = isArray(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areArraysEqual(a, b, state);\n }\n\n aArray = isArrayBuffer(a);\n bArray = isArrayBuffer(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areTypedArraysEqual(a, b, state);\n }\n\n // Since this is a custom object, use the classic `toString.call()` to get its\n // type. This is reasonably performant in modern environments like v8 and\n // SpiderMonkey, and allows for cross-realm comparison when other checks like\n // `instanceof` do not.\n const tag = getTag(a);\n\n if (tag !== getTag(b)) {\n return false;\n }\n\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n\n // If a simple object tag, then we can prioritize a simple object comparison because\n // it is likely a custom class.\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is `Promise`-like contracts. These should be\n // treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (\n typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state)\n );\n }\n\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n\n/**\n * Create the configuration object used for building comparators.\n */\nexport function createComparatorConfig<Meta>({\n circular,\n createCustomConfig,\n strict,\n}: CustomEqualCreatorOptions<Meta>): ComparatorConfig<Meta> {\n let config = {\n areArraysEqual: strict\n ? areObjectsEqualStrictDefault\n : areArraysEqualDefault,\n areDatesEqual: areDatesEqualDefault,\n areMapsEqual: strict\n ? combineComparators(areMapsEqualDefault, areObjectsEqualStrictDefault)\n : areMapsEqualDefault,\n areObjectsEqual: strict\n ? areObjectsEqualStrictDefault\n : areObjectsEqualDefault,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqualDefault,\n areRegExpsEqual: areRegExpsEqualDefault,\n areSetsEqual: strict\n ? combineComparators(areSetsEqualDefault, areObjectsEqualStrictDefault)\n : areSetsEqualDefault,\n areTypedArraysEqual: strict\n ? combineComparators(areTypedArraysEqual, areObjectsEqualStrictDefault)\n : areTypedArraysEqual,\n };\n\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n\n if (circular) {\n const areArraysEqual = createIsCircular(config.areArraysEqual);\n const areMapsEqual = createIsCircular(config.areMapsEqual);\n const areObjectsEqual = createIsCircular(config.areObjectsEqual);\n const areSetsEqual = createIsCircular(config.areSetsEqual);\n\n config = assign({}, config, {\n areArraysEqual,\n areMapsEqual,\n areObjectsEqual,\n areSetsEqual,\n });\n }\n\n return config;\n}\n","import { createComparator, createComparatorConfig } from './comparator';\nimport type {\n CircularState,\n CustomEqualCreatorOptions,\n DefaultState,\n} from './internalTypes';\nimport { createInternalComparator, sameValueZeroEqual } from './utils';\n\nexport { sameValueZeroEqual };\nexport * from './internalTypes';\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nexport const deepEqual = createCustomEqual();\n\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nexport const strictDeepEqual = createCustomEqual({ strict: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nexport const circularDeepEqual = createCustomEqual({ circular: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nexport const shallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nexport const strictShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nexport const circularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n strict: true,\n});\n\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nexport function createCustomEqual<Meta>(\n options: CustomEqualCreatorOptions<Meta> = {},\n) {\n const {\n circular,\n comparator,\n createInternalComparator: createCustomInternalComparator,\n createState,\n strict: baseStrict = false,\n } = options;\n\n const config = createComparatorConfig<Meta>(options);\n const isEqualCustom = createComparator(config);\n const isEqualCustomComparator =\n comparator ||\n (createCustomInternalComparator\n ? createCustomInternalComparator(isEqualCustom)\n : createInternalComparator(isEqualCustom));\n\n if (createState) {\n return function isEqual<A, B>(\n a: A,\n b: B,\n metaOverride?: Meta | undefined,\n ): boolean {\n const {\n cache = circular ? new WeakMap() : undefined,\n equals = isEqualCustomComparator,\n meta,\n strict = baseStrict,\n } = createState!(isEqualCustom);\n\n return isEqualCustom(a, b, {\n cache,\n equals,\n meta: metaOverride !== undefined ? metaOverride : meta,\n strict,\n } as CircularState<Meta>);\n };\n }\n\n if (circular) {\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, {\n cache: new WeakMap(),\n equals: isEqualCustomComparator,\n meta: undefined as Meta,\n strict: baseStrict,\n } as CircularState<Meta>);\n };\n }\n\n const state = Object.freeze({\n cache: undefined,\n equals: isEqualCustomComparator,\n meta: undefined,\n strict: baseStrict,\n });\n\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, state as DefaultState<Meta>);\n };\n}\n"],"names":["areObjectsEqualStrictDefault","areArraysEqualDefault","areDatesEqualDefault","areMapsEqualDefault","areObjectsEqualDefault","arePrimitiveWrappersEqualDefault","areRegExpsEqualDefault","areSetsEqualDefault","areArraysEqual","areMapsEqual","areObjectsEqual","areSetsEqual"],"mappings":";;AAWQ,IAAA,mBAAmB,GAA4B,MAAM,CAAA,mBAAlC,EAAE,qBAAqB,GAAK,MAAM,CAAA,qBAAX,CAAY;AACtD,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAE5C,IAAM,qBAAqB,GACzB,OAAO,WAAW,KAAK,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAEnE;;AAEG;AACa,SAAA,kBAAkB,CAChC,WAAwC,EACxC,WAAwC,EAAA;AAExC,IAAA,OAAO,SAAS,OAAO,CAAO,CAAI,EAAE,CAAI,EAAE,KAAkB,EAAA;AAC1D,QAAA,OAAO,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9D,KAAC,CAAC;AACJ,CAAC;AAED;;;AAGG;AACG,SAAU,wBAAwB,CACtC,OAAiC,EAAA;AAEjC,IAAA,OAAO,UACL,CAAM,EACN,CAAM,EACN,YAAiB,EACjB,YAAiB,EACjB,QAAa,EACb,QAAa,EACb,KAAkB,EAAA;QAElB,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9B,KAAC,CAAC;AACJ,CAAC;AAED;;;;AAIG;AACG,SAAU,gBAAgB,CAE9B,aAA4B,EAAA;AAC5B,IAAA,OAAO,SAAS,UAAU,CACxB,C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;gBACN,IAAI,EAAE,YAAY,KAAK,SAAS,GAAG,YAAY,GAAG,IAAI;AACtD,gBAAA,MAAM,EAAA,MAAA;AACgB,aAAA,CAAC,CAAC;AAC5B,SAAC,CAAC;AACH,KAAA;AAED,IAAA,IAAI,QAAQ,EAAE;AACZ,QAAA,OAAO,SAAS,MAAM,CAAO,CAAI,EAAE,CAAI,EAAA;AACrC,YAAA,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE;gBACzB,KAAK,EAAE,IAAI,OAAO,EAAE;AACpB,gBAAA,MAAM,EAAE,uBAAuB;AAC/B,gBAAA,IAAI,EAAE,SAAiB;AACvB,gBAAA,MAAM,EAAE,UAAU;AACI,aAAA,CAAC,CAAC;AAC5B,SAAC,CAAC;AACH,KAAA;AAED,IAAA,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;AAC1B,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,MAAM,EAAE,uBAAuB;AAC/B,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,MAAM,EAAE,UAAU;AACnB,KAAA,CAAC,CAAC;AAEH,IAAA,OAAO,SAAS,MAAM,CAAO,CAAI,EAAE,CAAI,EAAA;QACrC,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,KAA2B,CAAC,CAAC;AAC1D,KAAC,CAAC;AACJ;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import type { ComparatorConfig, CustomEqualCreatorOptions, EqualityComparator }
|
|
|
2
2
|
/**
|
|
3
3
|
* Create a comparator method based on the type-specific equality comparators passed.
|
|
4
4
|
*/
|
|
5
|
-
export declare function createComparator<Meta>({ areArraysEqual, areDatesEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
5
|
+
export declare function createComparator<Meta>({ areArraysEqual, areDatesEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
6
6
|
/**
|
|
7
7
|
* Create the configuration object used for building comparators.
|
|
8
8
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dictionary, State } from './internalTypes';
|
|
1
|
+
import type { Dictionary, State, TypedArray } from './internalTypes';
|
|
2
2
|
/**
|
|
3
3
|
* Whether the arrays are equal in value.
|
|
4
4
|
*/
|
|
@@ -31,3 +31,4 @@ export declare function areRegExpsEqual(a: RegExp, b: RegExp): boolean;
|
|
|
31
31
|
* Whether the `Set`s are equal in value.
|
|
32
32
|
*/
|
|
33
33
|
export declare function areSetsEqual(a: Set<any>, b: Set<any>, state: State<any>): boolean;
|
|
34
|
+
export declare function areTypedArraysEqual(a: TypedArray, b: TypedArray): boolean;
|
|
@@ -26,6 +26,7 @@ export interface ComparatorConfig<Meta> {
|
|
|
26
26
|
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
|
|
27
27
|
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
|
|
28
28
|
areSetsEqual: TypeEqualityComparator<any, Meta>;
|
|
29
|
+
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
29
30
|
}
|
|
30
31
|
export type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
|
|
31
32
|
export type CreateState<Meta> = (comparator: EqualityComparator<Meta>) => Partial<State<Meta>>;
|
|
@@ -33,6 +34,7 @@ export type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) =>
|
|
|
33
34
|
export type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
|
|
34
35
|
export type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
|
|
35
36
|
export type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
|
|
37
|
+
export type TypedArray = Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
|
|
36
38
|
export type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
|
|
37
39
|
export interface CustomEqualCreatorOptions<Meta> {
|
|
38
40
|
circular?: boolean;
|
|
@@ -23,6 +23,7 @@ export declare function getStrictProperties(object: Dictionary): Array<string |
|
|
|
23
23
|
* Whether the object contains the property passed as an own property.
|
|
24
24
|
*/
|
|
25
25
|
export declare const hasOwn: (o: object, v: PropertyKey) => boolean;
|
|
26
|
+
export declare function isArrayBuffer(value: any): value is ArrayBuffer;
|
|
26
27
|
/**
|
|
27
28
|
* Whether the values passed are strictly equal or both NaN.
|
|
28
29
|
*/
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
2
2
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3
|
+
var SUPPORTS_ARRAY_BUFFER = typeof ArrayBuffer === 'function' && Boolean(ArrayBuffer.isView);
|
|
3
4
|
/**
|
|
4
5
|
* Combine two comparators into a single comparators.
|
|
5
6
|
*/
|
|
@@ -55,6 +56,9 @@ var hasOwn = Object.hasOwn ||
|
|
|
55
56
|
(function (object, property) {
|
|
56
57
|
return hasOwnProperty.call(object, property);
|
|
57
58
|
});
|
|
59
|
+
function isArrayBuffer(value) {
|
|
60
|
+
return SUPPORTS_ARRAY_BUFFER && ArrayBuffer.isView(value);
|
|
61
|
+
}
|
|
58
62
|
/**
|
|
59
63
|
* Whether the values passed are strictly equal or both NaN.
|
|
60
64
|
*/
|
|
@@ -233,6 +237,18 @@ function areSetsEqual(a, b, state) {
|
|
|
233
237
|
}
|
|
234
238
|
return isValueEqual;
|
|
235
239
|
}
|
|
240
|
+
function areTypedArraysEqual(a, b) {
|
|
241
|
+
var index = a.length;
|
|
242
|
+
if (b.length !== index) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
while (index-- > 0) {
|
|
246
|
+
if (a[index] !== b[index]) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
236
252
|
|
|
237
253
|
var ARGUMENTS_TAG = '[object Arguments]';
|
|
238
254
|
var BOOLEAN_TAG = '[object Boolean]';
|
|
@@ -250,7 +266,7 @@ var getTag = Object.prototype.toString.call.bind(Object.prototype.toString);
|
|
|
250
266
|
* Create a comparator method based on the type-specific equality comparators passed.
|
|
251
267
|
*/
|
|
252
268
|
function createComparator(_a) {
|
|
253
|
-
var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areMapsEqual = _a.areMapsEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual;
|
|
269
|
+
var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areMapsEqual = _a.areMapsEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, areTypedArraysEqual = _a.areTypedArraysEqual;
|
|
254
270
|
/**
|
|
255
271
|
* compare the value of the two objects and return true if they are equivalent in values
|
|
256
272
|
*/
|
|
@@ -280,6 +296,12 @@ function createComparator(_a) {
|
|
|
280
296
|
if (a.constructor === Object && b.constructor === Object) {
|
|
281
297
|
return areObjectsEqual(a, b, state);
|
|
282
298
|
}
|
|
299
|
+
// In strict mode, constructors should match. We placed this after the plain object check
|
|
300
|
+
// because the constructors must match to meet plain object requirements (must both be `Object`
|
|
301
|
+
// in the given Realm), so it slightly improves performance on a very common use-case.
|
|
302
|
+
if (state.strict && a.constructor !== b.constructor) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
283
305
|
// `isArray()` works on subclasses and is cross-realm, so we can again avoid
|
|
284
306
|
// the `toString.call()` cost unless necessary by just checking if either
|
|
285
307
|
// and then both are arrays.
|
|
@@ -288,6 +310,11 @@ function createComparator(_a) {
|
|
|
288
310
|
if (aArray || bArray) {
|
|
289
311
|
return aArray === bArray && areArraysEqual(a, b, state);
|
|
290
312
|
}
|
|
313
|
+
aArray = isArrayBuffer(a);
|
|
314
|
+
bArray = isArrayBuffer(b);
|
|
315
|
+
if (aArray || bArray) {
|
|
316
|
+
return aArray === bArray && areTypedArraysEqual(a, b, state);
|
|
317
|
+
}
|
|
291
318
|
// Since this is a custom object, use the classic `toString.call()` to get its
|
|
292
319
|
// type. This is reasonably performant in modern environments like v8 and
|
|
293
320
|
// SpiderMonkey, and allows for cross-realm comparison when other checks like
|
|
@@ -363,6 +390,9 @@ function createComparatorConfig(_a) {
|
|
|
363
390
|
areSetsEqual: strict
|
|
364
391
|
? combineComparators(areSetsEqual, areObjectsEqualStrict)
|
|
365
392
|
: areSetsEqual,
|
|
393
|
+
areTypedArraysEqual: strict
|
|
394
|
+
? combineComparators(areTypedArraysEqual, areObjectsEqualStrict)
|
|
395
|
+
: areTypedArraysEqual,
|
|
366
396
|
};
|
|
367
397
|
if (createCustomConfig) {
|
|
368
398
|
config = assign({}, config, createCustomConfig(config));
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/utils.ts","../../src/equals.ts","../../src/comparator.ts","../../src/index.ts"],"sourcesContent":["import {\n AnyEqualityComparator,\n BaseCircular,\n CircularState,\n Dictionary,\n EqualityComparator,\n InternalEqualityComparator,\n State,\n TypeEqualityComparator,\n} from './internalTypes';\n\nconst { getOwnPropertyNames, getOwnPropertySymbols } = Object;\nconst { hasOwnProperty } = Object.prototype;\n\n/**\n * Combine two comparators into a single comparators.\n */\nexport function combineComparators<Meta>(\n comparatorA: AnyEqualityComparator<Meta>,\n comparatorB: AnyEqualityComparator<Meta>,\n) {\n return function isEqual<A, B>(a: A, b: B, state: State<Meta>) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nexport function createInternalComparator<Meta>(\n compare: EqualityComparator<Meta>,\n): InternalEqualityComparator<Meta> {\n return function (\n a: any,\n b: any,\n _indexOrKeyA: any,\n _indexOrKeyB: any,\n _parentA: any,\n _parentB: any,\n state: State<Meta>,\n ) {\n return compare(a, b, state);\n };\n}\n\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nexport function createIsCircular<\n AreItemsEqual extends TypeEqualityComparator<any, any>,\n>(areItemsEqual: AreItemsEqual): AreItemsEqual {\n return function isCircular(\n a: any,\n b: any,\n state: CircularState<BaseCircular>,\n ) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n\n const { cache } = state;\n\n const cachedA = cache.get(a);\n const cachedB = cache.get(b);\n\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n\n cache.set(a, b);\n cache.set(b, a);\n\n const result = areItemsEqual(a, b, state);\n\n cache.delete(a);\n cache.delete(b);\n\n return result;\n } as AreItemsEqual;\n}\n\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nexport function getStrictProperties(\n object: Dictionary,\n): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object),\n );\n}\n\n/**\n * Whether the object contains the property passed as an own property.\n */\nexport const hasOwn =\n Object.hasOwn ||\n ((object: Dictionary, property: number | string | symbol) =>\n hasOwnProperty.call(object, property));\n\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nexport function sameValueZeroEqual(a: any, b: any): boolean {\n return a || b ? a === b : a === b || (a !== a && b !== b);\n}\n","import { getStrictProperties, hasOwn, sameValueZeroEqual } from './utils';\nimport type { Dictionary, State } from './internalTypes';\n\nconst OWNER = '_owner';\n\nconst { getOwnPropertyDescriptor, keys } = Object;\n\n/**\n * Whether the arrays are equal in value.\n */\nexport function areArraysEqual(a: any[], b: any[], state: State<any>) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the dates passed are equal in value.\n */\nexport function areDatesEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n\n/**\n * Whether the `Map`s are equal in value.\n */\nexport function areMapsEqual(\n a: Map<any, any>,\n b: Map<any, any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n let indexA = 0;\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndexB = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndexB] &&\n (hasMatch =\n state.equals(aKey, bKey, indexA, matchIndexB, a, b, state) &&\n state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndexB] = true;\n }\n\n matchIndexB++;\n });\n\n indexA++;\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\n/**\n * Whether the objects are equal in value.\n */\nexport function areObjectsEqual(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = keys(a);\n\n let index = properties.length;\n\n if (keys(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (\n !hasOwn(b, property) ||\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nexport function areObjectsEqualStrict(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = getStrictProperties(a);\n\n let index = properties.length;\n\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n let descriptorA: ReturnType<typeof getOwnPropertyDescriptor>;\n let descriptorB: ReturnType<typeof getOwnPropertyDescriptor>;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (!hasOwn(b, property)) {\n return false;\n }\n\n if (\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n\n if (\n (descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nexport function arePrimitiveWrappersEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n\n/**\n * Whether the regexps passed are equal in value.\n */\nexport function areRegExpsEqual(a: RegExp, b: RegExp): boolean {\n return a.source === b.source && a.flags === b.flags;\n}\n\n/**\n * Whether the `Set`s are equal in value.\n */\nexport function areSetsEqual(\n a: Set<any>,\n b: Set<any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndex = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndex] &&\n (hasMatch = state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndex] = true;\n }\n\n matchIndex++;\n });\n\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n","import {\n areArraysEqual as areArraysEqualDefault,\n areDatesEqual as areDatesEqualDefault,\n areMapsEqual as areMapsEqualDefault,\n areObjectsEqual as areObjectsEqualDefault,\n areObjectsEqualStrict as areObjectsEqualStrictDefault,\n arePrimitiveWrappersEqual as arePrimitiveWrappersEqualDefault,\n areRegExpsEqual as areRegExpsEqualDefault,\n areSetsEqual as areSetsEqualDefault,\n} from './equals';\nimport { combineComparators, createIsCircular } from './utils';\nimport type {\n ComparatorConfig,\n CustomEqualCreatorOptions,\n EqualityComparator,\n State,\n} from './internalTypes';\n\nconst ARGUMENTS_TAG = '[object Arguments]';\nconst BOOLEAN_TAG = '[object Boolean]';\nconst DATE_TAG = '[object Date]';\nconst MAP_TAG = '[object Map]';\nconst NUMBER_TAG = '[object Number]';\nconst OBJECT_TAG = '[object Object]';\nconst REG_EXP_TAG = '[object RegExp]';\nconst SET_TAG = '[object Set]';\nconst STRING_TAG = '[object String]';\n\nconst { isArray } = Array;\nconst { assign } = Object;\nconst getTag = Object.prototype.toString.call.bind(\n Object.prototype.toString,\n) as (a: object) => string;\n\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nexport function createComparator<Meta>({\n areArraysEqual,\n areDatesEqual,\n areMapsEqual,\n areObjectsEqual,\n arePrimitiveWrappersEqual,\n areRegExpsEqual,\n areSetsEqual,\n}: ComparatorConfig<Meta>): EqualityComparator<Meta> {\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a: any, b: any, state: State<Meta>): boolean {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n\n // If the items are not non-nullish objects, then the only possibility\n // of them being equal but not strictly is if they are both `NaN`. Since\n // `NaN` is uniquely not equal to itself, we can use self-comparison of\n // both objects, which is faster than `isNaN()`.\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return a !== a && b !== b;\n }\n\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid the `toString.call()` cost unless necessary.\n if (a.constructor === Object && b.constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n\n // `isArray()` works on subclasses and is cross-realm, so we can again avoid\n // the `toString.call()` cost unless necessary by just checking if either\n // and then both are arrays.\n const aArray = isArray(a);\n const bArray = isArray(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areArraysEqual(a, b, state);\n }\n\n // Since this is a custom object, use the classic `toString.call()` to get its\n // type. This is reasonably performant in modern environments like v8 and\n // SpiderMonkey, and allows for cross-realm comparison when other checks like\n // `instanceof` do not.\n const tag = getTag(a);\n\n if (tag !== getTag(b)) {\n return false;\n }\n\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n\n // If a simple object tag, then we can prioritize a simple object comparison because\n // it is likely a custom class.\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is `Promise`-like contracts. These should be\n // treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (\n typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state)\n );\n }\n\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n\n/**\n * Create the configuration object used for building comparators.\n */\nexport function createComparatorConfig<Meta>({\n circular,\n createCustomConfig,\n strict,\n}: CustomEqualCreatorOptions<Meta>): ComparatorConfig<Meta> {\n let config = {\n areArraysEqual: strict\n ? areObjectsEqualStrictDefault\n : areArraysEqualDefault,\n areDatesEqual: areDatesEqualDefault,\n areMapsEqual: strict\n ? combineComparators(areMapsEqualDefault, areObjectsEqualStrictDefault)\n : areMapsEqualDefault,\n areObjectsEqual: strict\n ? areObjectsEqualStrictDefault\n : areObjectsEqualDefault,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqualDefault,\n areRegExpsEqual: areRegExpsEqualDefault,\n areSetsEqual: strict\n ? combineComparators(areSetsEqualDefault, areObjectsEqualStrictDefault)\n : areSetsEqualDefault,\n };\n\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n\n if (circular) {\n const areArraysEqual = createIsCircular(config.areArraysEqual);\n const areMapsEqual = createIsCircular(config.areMapsEqual);\n const areObjectsEqual = createIsCircular(config.areObjectsEqual);\n const areSetsEqual = createIsCircular(config.areSetsEqual);\n\n config = assign({}, config, {\n areArraysEqual,\n areMapsEqual,\n areObjectsEqual,\n areSetsEqual,\n });\n }\n\n return config;\n}\n","import { createComparator, createComparatorConfig } from './comparator';\nimport type {\n CircularState,\n CustomEqualCreatorOptions,\n DefaultState,\n} from './internalTypes';\nimport { createInternalComparator, sameValueZeroEqual } from './utils';\n\nexport { sameValueZeroEqual };\nexport * from './internalTypes';\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nexport const deepEqual = createCustomEqual();\n\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nexport const strictDeepEqual = createCustomEqual({ strict: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nexport const circularDeepEqual = createCustomEqual({ circular: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nexport const shallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nexport const strictShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nexport const circularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n strict: true,\n});\n\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nexport function createCustomEqual<Meta>(\n options: CustomEqualCreatorOptions<Meta> = {},\n) {\n const {\n circular,\n comparator,\n createInternalComparator: createCustomInternalComparator,\n createState,\n strict: baseStrict = false,\n } = options;\n\n const config = createComparatorConfig<Meta>(options);\n const isEqualCustom = createComparator(config);\n const isEqualCustomComparator =\n comparator ||\n (createCustomInternalComparator\n ? createCustomInternalComparator(isEqualCustom)\n : createInternalComparator(isEqualCustom));\n\n if (createState) {\n return function isEqual<A, B>(\n a: A,\n b: B,\n metaOverride?: Meta | undefined,\n ): boolean {\n const {\n cache = circular ? new WeakMap() : undefined,\n equals = isEqualCustomComparator,\n meta,\n strict = baseStrict,\n } = createState!(isEqualCustom);\n\n return isEqualCustom(a, b, {\n cache,\n equals,\n meta: metaOverride !== undefined ? metaOverride : meta,\n strict,\n } as CircularState<Meta>);\n };\n }\n\n if (circular) {\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, {\n cache: new WeakMap(),\n equals: isEqualCustomComparator,\n meta: undefined as Meta,\n strict: baseStrict,\n } as CircularState<Meta>);\n };\n }\n\n const state = Object.freeze({\n cache: undefined,\n equals: isEqualCustomComparator,\n meta: undefined,\n strict: baseStrict,\n });\n\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, state as DefaultState<Meta>);\n };\n}\n"],"names":["areObjectsEqualStrictDefault","areArraysEqualDefault","areDatesEqualDefault","areMapsEqualDefault","areObjectsEqualDefault","arePrimitiveWrappersEqualDefault","areRegExpsEqualDefault","areSetsEqualDefault","areArraysEqual","areMapsEqual","areObjectsEqual","areSetsEqual"],"mappings":"AAWQ,IAAA,mBAAmB,GAA4B,MAAM,CAAA,mBAAlC,EAAE,qBAAqB,GAAK,MAAM,CAAA,qBAAX,CAAY;AACtD,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAE5C;;AAEG;AACa,SAAA,kBAAkB,CAChC,WAAwC,EACxC,WAAwC,EAAA;AAExC,IAAA,OAAO,SAAS,OAAO,CAAO,CAAI,EAAE,CAAI,EAAE,KAAkB,EAAA;AAC1D,QAAA,OAAO,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9D,KAAC,CAAC;AACJ,CAAC;AAED;;;AAGG;AACG,SAAU,wBAAwB,CACtC,OAAiC,EAAA;AAEjC,IAAA,OAAO,UACL,CAAM,EACN,CAAM,EACN,YAAiB,EACjB,YAAiB,EACjB,QAAa,EACb,QAAa,EACb,KAAkB,EAAA;QAElB,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9B,KAAC,CAAC;AACJ,CAAC;AAED;;;;AAIG;AACG,SAAU,gBAAgB,CAE9B,aAA4B,EAAA;AAC5B,IAAA,OAAO,SAAS,UAAU,CACxB,CAAM,EACN,CAAM,EACN,KAAkC,EAAA;AAElC,QAAA,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;YAC9D,OAAO,aAAa,CAAC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AAG,YAAY,GAAG,IAAI;AACtD,gBAAA,MAAM,EAAA,MAAA;AACgB,aAAA,CAAC,CAAC;AAC5B,SAAC,CAAC;AACH,KAAA;AAED,IAAA,IAAI,QAAQ,EAAE;AACZ,QAAA,OAAO,SAAS,MAAM,CAAO,CAAI,EAAE,CAAI,EAAA;AACrC,YAAA,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE;gBACzB,KAAK,EAAE,IAAI,OAAO,EAAE;AACpB,gBAAA,MAAM,EAAE,uBAAuB;AAC/B,gBAAA,IAAI,EAAE,SAAiB;AACvB,gBAAA,MAAM,EAAE,UAAU;AACI,aAAA,CAAC,CAAC;AAC5B,SAAC,CAAC;AACH,KAAA;AAED,IAAA,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;AAC1B,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,MAAM,EAAE,uBAAuB;AAC/B,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,MAAM,EAAE,UAAU;AACnB,KAAA,CAAC,CAAC;AAEH,IAAA,OAAO,SAAS,MAAM,CAAO,CAAI,EAAE,CAAI,EAAA;QACrC,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,KAA2B,CAAC,CAAC;AAC1D,KAAC,CAAC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/utils.ts","../../src/equals.ts","../../src/comparator.ts","../../src/index.ts"],"sourcesContent":["import {\n AnyEqualityComparator,\n BaseCircular,\n CircularState,\n Dictionary,\n EqualityComparator,\n InternalEqualityComparator,\n State,\n TypeEqualityComparator,\n} from './internalTypes';\n\nconst { getOwnPropertyNames, getOwnPropertySymbols } = Object;\nconst { hasOwnProperty } = Object.prototype;\n\nconst SUPPORTS_ARRAY_BUFFER =\n typeof ArrayBuffer === 'function' && Boolean(ArrayBuffer.isView);\n\n/**\n * Combine two comparators into a single comparators.\n */\nexport function combineComparators<Meta>(\n comparatorA: AnyEqualityComparator<Meta>,\n comparatorB: AnyEqualityComparator<Meta>,\n) {\n return function isEqual<A, B>(a: A, b: B, state: State<Meta>) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nexport function createInternalComparator<Meta>(\n compare: EqualityComparator<Meta>,\n): InternalEqualityComparator<Meta> {\n return function (\n a: any,\n b: any,\n _indexOrKeyA: any,\n _indexOrKeyB: any,\n _parentA: any,\n _parentB: any,\n state: State<Meta>,\n ) {\n return compare(a, b, state);\n };\n}\n\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nexport function createIsCircular<\n AreItemsEqual extends TypeEqualityComparator<any, any>,\n>(areItemsEqual: AreItemsEqual): AreItemsEqual {\n return function isCircular(\n a: any,\n b: any,\n state: CircularState<BaseCircular>,\n ) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n\n const { cache } = state;\n\n const cachedA = cache.get(a);\n const cachedB = cache.get(b);\n\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n\n cache.set(a, b);\n cache.set(b, a);\n\n const result = areItemsEqual(a, b, state);\n\n cache.delete(a);\n cache.delete(b);\n\n return result;\n } as AreItemsEqual;\n}\n\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nexport function getStrictProperties(\n object: Dictionary,\n): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object),\n );\n}\n\n/**\n * Whether the object contains the property passed as an own property.\n */\nexport const hasOwn =\n Object.hasOwn ||\n ((object: Dictionary, property: number | string | symbol) =>\n hasOwnProperty.call(object, property));\n\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return SUPPORTS_ARRAY_BUFFER && ArrayBuffer.isView(value);\n}\n\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nexport function sameValueZeroEqual(a: any, b: any): boolean {\n return a || b ? a === b : a === b || (a !== a && b !== b);\n}\n","import { getStrictProperties, hasOwn, sameValueZeroEqual } from './utils';\nimport type { Dictionary, State, TypedArray } from './internalTypes';\n\nconst OWNER = '_owner';\n\nconst { getOwnPropertyDescriptor, keys } = Object;\n\n/**\n * Whether the arrays are equal in value.\n */\nexport function areArraysEqual(a: any[], b: any[], state: State<any>) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the dates passed are equal in value.\n */\nexport function areDatesEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n\n/**\n * Whether the `Map`s are equal in value.\n */\nexport function areMapsEqual(\n a: Map<any, any>,\n b: Map<any, any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n let indexA = 0;\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndexB = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndexB] &&\n (hasMatch =\n state.equals(aKey, bKey, indexA, matchIndexB, a, b, state) &&\n state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndexB] = true;\n }\n\n matchIndexB++;\n });\n\n indexA++;\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\n/**\n * Whether the objects are equal in value.\n */\nexport function areObjectsEqual(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = keys(a);\n\n let index = properties.length;\n\n if (keys(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (\n !hasOwn(b, property) ||\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nexport function areObjectsEqualStrict(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = getStrictProperties(a);\n\n let index = properties.length;\n\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n let descriptorA: ReturnType<typeof getOwnPropertyDescriptor>;\n let descriptorB: ReturnType<typeof getOwnPropertyDescriptor>;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (!hasOwn(b, property)) {\n return false;\n }\n\n if (\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n\n if (\n (descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nexport function arePrimitiveWrappersEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n\n/**\n * Whether the regexps passed are equal in value.\n */\nexport function areRegExpsEqual(a: RegExp, b: RegExp): boolean {\n return a.source === b.source && a.flags === b.flags;\n}\n\n/**\n * Whether the `Set`s are equal in value.\n */\nexport function areSetsEqual(\n a: Set<any>,\n b: Set<any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndex = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndex] &&\n (hasMatch = state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndex] = true;\n }\n\n matchIndex++;\n });\n\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\nexport function areTypedArraysEqual(a: TypedArray, b: TypedArray) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (a[index] !== b[index]) {\n return false;\n }\n }\n\n return true;\n}\n","import {\n areArraysEqual as areArraysEqualDefault,\n areDatesEqual as areDatesEqualDefault,\n areMapsEqual as areMapsEqualDefault,\n areObjectsEqual as areObjectsEqualDefault,\n areObjectsEqualStrict as areObjectsEqualStrictDefault,\n arePrimitiveWrappersEqual as arePrimitiveWrappersEqualDefault,\n areRegExpsEqual as areRegExpsEqualDefault,\n areSetsEqual as areSetsEqualDefault,\n areTypedArraysEqual,\n} from './equals';\nimport { combineComparators, createIsCircular, isArrayBuffer } from './utils';\nimport type {\n ComparatorConfig,\n CustomEqualCreatorOptions,\n EqualityComparator,\n State,\n} from './internalTypes';\n\nconst ARGUMENTS_TAG = '[object Arguments]';\nconst BOOLEAN_TAG = '[object Boolean]';\nconst DATE_TAG = '[object Date]';\nconst MAP_TAG = '[object Map]';\nconst NUMBER_TAG = '[object Number]';\nconst OBJECT_TAG = '[object Object]';\nconst REG_EXP_TAG = '[object RegExp]';\nconst SET_TAG = '[object Set]';\nconst STRING_TAG = '[object String]';\n\nconst { isArray } = Array;\nconst { assign } = Object;\nconst getTag = Object.prototype.toString.call.bind(\n Object.prototype.toString,\n) as (a: object) => string;\n\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nexport function createComparator<Meta>({\n areArraysEqual,\n areDatesEqual,\n areMapsEqual,\n areObjectsEqual,\n arePrimitiveWrappersEqual,\n areRegExpsEqual,\n areSetsEqual,\n areTypedArraysEqual,\n}: ComparatorConfig<Meta>): EqualityComparator<Meta> {\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a: any, b: any, state: State<Meta>): boolean {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n\n // If the items are not non-nullish objects, then the only possibility\n // of them being equal but not strictly is if they are both `NaN`. Since\n // `NaN` is uniquely not equal to itself, we can use self-comparison of\n // both objects, which is faster than `isNaN()`.\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return a !== a && b !== b;\n }\n\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid the `toString.call()` cost unless necessary.\n if (a.constructor === Object && b.constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n\n // In strict mode, constructors should match. We placed this after the plain object check\n // because the constructors must match to meet plain object requirements (must both be `Object`\n // in the given Realm), so it slightly improves performance on a very common use-case.\n if (state.strict && a.constructor !== b.constructor) {\n return false;\n }\n\n // `isArray()` works on subclasses and is cross-realm, so we can again avoid\n // the `toString.call()` cost unless necessary by just checking if either\n // and then both are arrays.\n let aArray = isArray(a);\n let bArray = isArray(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areArraysEqual(a, b, state);\n }\n\n aArray = isArrayBuffer(a);\n bArray = isArrayBuffer(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areTypedArraysEqual(a, b, state);\n }\n\n // Since this is a custom object, use the classic `toString.call()` to get its\n // type. This is reasonably performant in modern environments like v8 and\n // SpiderMonkey, and allows for cross-realm comparison when other checks like\n // `instanceof` do not.\n const tag = getTag(a);\n\n if (tag !== getTag(b)) {\n return false;\n }\n\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n\n // If a simple object tag, then we can prioritize a simple object comparison because\n // it is likely a custom class.\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is `Promise`-like contracts. These should be\n // treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (\n typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state)\n );\n }\n\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n\n/**\n * Create the configuration object used for building comparators.\n */\nexport function createComparatorConfig<Meta>({\n circular,\n createCustomConfig,\n strict,\n}: CustomEqualCreatorOptions<Meta>): ComparatorConfig<Meta> {\n let config = {\n areArraysEqual: strict\n ? areObjectsEqualStrictDefault\n : areArraysEqualDefault,\n areDatesEqual: areDatesEqualDefault,\n areMapsEqual: strict\n ? combineComparators(areMapsEqualDefault, areObjectsEqualStrictDefault)\n : areMapsEqualDefault,\n areObjectsEqual: strict\n ? areObjectsEqualStrictDefault\n : areObjectsEqualDefault,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqualDefault,\n areRegExpsEqual: areRegExpsEqualDefault,\n areSetsEqual: strict\n ? combineComparators(areSetsEqualDefault, areObjectsEqualStrictDefault)\n : areSetsEqualDefault,\n areTypedArraysEqual: strict\n ? combineComparators(areTypedArraysEqual, areObjectsEqualStrictDefault)\n : areTypedArraysEqual,\n };\n\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n\n if (circular) {\n const areArraysEqual = createIsCircular(config.areArraysEqual);\n const areMapsEqual = createIsCircular(config.areMapsEqual);\n const areObjectsEqual = createIsCircular(config.areObjectsEqual);\n const areSetsEqual = createIsCircular(config.areSetsEqual);\n\n config = assign({}, config, {\n areArraysEqual,\n areMapsEqual,\n areObjectsEqual,\n areSetsEqual,\n });\n }\n\n return config;\n}\n","import { createComparator, createComparatorConfig } from './comparator';\nimport type {\n CircularState,\n CustomEqualCreatorOptions,\n DefaultState,\n} from './internalTypes';\nimport { createInternalComparator, sameValueZeroEqual } from './utils';\n\nexport { sameValueZeroEqual };\nexport * from './internalTypes';\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nexport const deepEqual = createCustomEqual();\n\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nexport const strictDeepEqual = createCustomEqual({ strict: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nexport const circularDeepEqual = createCustomEqual({ circular: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nexport const shallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nexport const strictShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nexport const circularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n strict: true,\n});\n\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nexport function createCustomEqual<Meta>(\n options: CustomEqualCreatorOptions<Meta> = {},\n) {\n const {\n circular,\n comparator,\n createInternalComparator: createCustomInternalComparator,\n createState,\n strict: baseStrict = false,\n } = options;\n\n const config = createComparatorConfig<Meta>(options);\n const isEqualCustom = createComparator(config);\n const isEqualCustomComparator =\n comparator ||\n (createCustomInternalComparator\n ? createCustomInternalComparator(isEqualCustom)\n : createInternalComparator(isEqualCustom));\n\n if (createState) {\n return function isEqual<A, B>(\n a: A,\n b: B,\n metaOverride?: Meta | undefined,\n ): boolean {\n const {\n cache = circular ? new WeakMap() : undefined,\n equals = isEqualCustomComparator,\n meta,\n strict = baseStrict,\n } = createState!(isEqualCustom);\n\n return isEqualCustom(a, b, {\n cache,\n equals,\n meta: metaOverride !== undefined ? metaOverride : meta,\n strict,\n } as CircularState<Meta>);\n };\n }\n\n if (circular) {\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, {\n cache: new WeakMap(),\n equals: isEqualCustomComparator,\n meta: undefined as Meta,\n strict: baseStrict,\n } as CircularState<Meta>);\n };\n }\n\n const state = Object.freeze({\n cache: undefined,\n equals: isEqualCustomComparator,\n meta: undefined,\n strict: baseStrict,\n });\n\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, state as DefaultState<Meta>);\n };\n}\n"],"names":["areObjectsEqualStrictDefault","areArraysEqualDefault","areDatesEqualDefault","areMapsEqualDefault","areObjectsEqualDefault","arePrimitiveWrappersEqualDefault","areRegExpsEqualDefault","areSetsEqualDefault","areArraysEqual","areMapsEqual","areObjectsEqual","areSetsEqual"],"mappings":"AAWQ,IAAA,mBAAmB,GAA4B,MAAM,CAAA,mBAAlC,EAAE,qBAAqB,GAAK,MAAM,CAAA,qBAAX,CAAY;AACtD,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAE5C,IAAM,qBAAqB,GACzB,OAAO,WAAW,KAAK,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAEnE;;AAEG;AACa,SAAA,kBAAkB,CAChC,WAAwC,EACxC,WAAwC,EAAA;AAExC,IAAA,OAAO,SAAS,OAAO,CAAO,CAAI,EAAE,CAAI,EAAE,KAAkB,EAAA;AAC1D,QAAA,OAAO,WAAW,CAAC,CAAC,EAAE,CAAC,E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E,CAAC,EAAE,KAA2B,CAAC,CAAC;AAC1D,KAAC,CAAC;AACJ;;;;"}
|
|
@@ -2,7 +2,7 @@ import type { ComparatorConfig, CustomEqualCreatorOptions, EqualityComparator }
|
|
|
2
2
|
/**
|
|
3
3
|
* Create a comparator method based on the type-specific equality comparators passed.
|
|
4
4
|
*/
|
|
5
|
-
export declare function createComparator<Meta>({ areArraysEqual, areDatesEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
5
|
+
export declare function createComparator<Meta>({ areArraysEqual, areDatesEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
6
6
|
/**
|
|
7
7
|
* Create the configuration object used for building comparators.
|
|
8
8
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dictionary, State } from './internalTypes';
|
|
1
|
+
import type { Dictionary, State, TypedArray } from './internalTypes';
|
|
2
2
|
/**
|
|
3
3
|
* Whether the arrays are equal in value.
|
|
4
4
|
*/
|
|
@@ -31,3 +31,4 @@ export declare function areRegExpsEqual(a: RegExp, b: RegExp): boolean;
|
|
|
31
31
|
* Whether the `Set`s are equal in value.
|
|
32
32
|
*/
|
|
33
33
|
export declare function areSetsEqual(a: Set<any>, b: Set<any>, state: State<any>): boolean;
|
|
34
|
+
export declare function areTypedArraysEqual(a: TypedArray, b: TypedArray): boolean;
|
|
@@ -26,6 +26,7 @@ export interface ComparatorConfig<Meta> {
|
|
|
26
26
|
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
|
|
27
27
|
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
|
|
28
28
|
areSetsEqual: TypeEqualityComparator<any, Meta>;
|
|
29
|
+
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
29
30
|
}
|
|
30
31
|
export type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
|
|
31
32
|
export type CreateState<Meta> = (comparator: EqualityComparator<Meta>) => Partial<State<Meta>>;
|
|
@@ -33,6 +34,7 @@ export type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) =>
|
|
|
33
34
|
export type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
|
|
34
35
|
export type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
|
|
35
36
|
export type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
|
|
37
|
+
export type TypedArray = Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
|
|
36
38
|
export type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
|
|
37
39
|
export interface CustomEqualCreatorOptions<Meta> {
|
|
38
40
|
circular?: boolean;
|
|
@@ -23,6 +23,7 @@ export declare function getStrictProperties(object: Dictionary): Array<string |
|
|
|
23
23
|
* Whether the object contains the property passed as an own property.
|
|
24
24
|
*/
|
|
25
25
|
export declare const hasOwn: (o: object, v: PropertyKey) => boolean;
|
|
26
|
+
export declare function isArrayBuffer(value: any): value is ArrayBuffer;
|
|
26
27
|
/**
|
|
27
28
|
* Whether the values passed are strictly equal or both NaN.
|
|
28
29
|
*/
|
package/dist/min/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e
|
|
1
|
+
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self)["fast-equals"]={})}(this,(function(r){"use strict";var e=Object.getOwnPropertyNames,t=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,n="function"==typeof ArrayBuffer&&Boolean(ArrayBuffer.isView);function u(r,e){return function(t,a,n){return r(t,a,n)&&e(t,a,n)}}function o(r){return function(e,t,a){if(!e||!t||"object"!=typeof e||"object"!=typeof t)return r(e,t,a);var n=a.cache,u=n.get(e),o=n.get(t);if(u&&o)return u===t&&o===e;n.set(e,t),n.set(t,e);var c=r(e,t,a);return n.delete(e),n.delete(t),c}}function c(r){return e(r).concat(t(r))}var i=Object.hasOwn||function(r,e){return a.call(r,e)};function f(r){return n&&ArrayBuffer.isView(r)}function l(r,e){return r||e?r===e:r===e||r!=r&&e!=e}var s="_owner",p=Object.getOwnPropertyDescriptor,q=Object.keys;function b(r,e,t){var a=r.length;if(e.length!==a)return!1;for(;a-- >0;)if(!t.equals(r[a],e[a],a,a,r,e,t))return!1;return!0}function y(r,e){return l(r.getTime(),e.getTime())}function E(r,e,t){var a=r.size===e.size;if(a&&r.size){var n={},u=0;r.forEach((function(o,c){if(a){var i=!1,f=0;e.forEach((function(a,l){i||n[f]||!(i=t.equals(c,l,u,f,r,e,t)&&t.equals(o,a,c,l,r,e,t))||(n[f]=!0),f++})),u++,a=i}}))}return a}function v(r,e,t){var a,n=q(r),u=n.length;if(q(e).length!==u)return!1;for(;u-- >0;){if((a=n[u])===s&&(r.$$typeof||e.$$typeof)&&r.$$typeof!==e.$$typeof)return!1;if(!i(e,a)||!t.equals(r[a],e[a],a,a,r,e,t))return!1}return!0}function j(r,e,t){var a,n,u,o=c(r),f=o.length;if(c(e).length!==f)return!1;for(;f-- >0;){if((a=o[f])===s&&(r.$$typeof||e.$$typeof)&&r.$$typeof!==e.$$typeof)return!1;if(!i(e,a))return!1;if(!t.equals(r[a],e[a],a,a,r,e,t))return!1;if(n=p(r,a),u=p(e,a),(n||u)&&(!n||!u||n.configurable!==u.configurable||n.enumerable!==u.enumerable||n.writable!==u.writable))return!1}return!0}function g(r,e){return l(r.valueOf(),e.valueOf())}function h(r,e){return r.source===e.source&&r.flags===e.flags}function d(r,e,t){var a=r.size===e.size;if(a&&r.size){var n={};r.forEach((function(u,o){if(a){var c=!1,i=0;e.forEach((function(a,f){c||n[i]||!(c=t.equals(u,a,o,f,r,e,t))||(n[i]=!0),i++})),a=c}}))}return a}function m(r,e){var t=r.length;if(e.length!==t)return!1;for(;t-- >0;)if(r[t]!==e[t])return!1;return!0}var O="[object Arguments]",w="[object Boolean]",$="[object Date]",S="[object Map]",A="[object Number]",z="[object Object]",D="[object RegExp]",M="[object Set]",x="[object String]",C=Array.isArray,P=Object.assign,T=Object.prototype.toString.call.bind(Object.prototype.toString);var B=_(),W=_({strict:!0}),k=_({circular:!0}),R=_({circular:!0,strict:!0}),V=_({comparator:l}),N=_({comparator:l,strict:!0}),I=_({comparator:l,circular:!0}),Z=_({comparator:l,circular:!0,strict:!0});function _(r){void 0===r&&(r={});var e,t=r.circular,a=r.comparator,n=r.createInternalComparator,c=r.createState,i=r.strict,l=void 0!==i&&i,s=function(r){var e=r.circular,t=r.createCustomConfig,a=r.strict,n={areArraysEqual:a?j:b,areDatesEqual:y,areMapsEqual:a?u(E,j):E,areObjectsEqual:a?j:v,arePrimitiveWrappersEqual:g,areRegExpsEqual:h,areSetsEqual:a?u(d,j):d,areTypedArraysEqual:a?u(m,j):m};if(t&&(n=P({},n,t(n))),e){var c=o(n.areArraysEqual),i=o(n.areMapsEqual),f=o(n.areObjectsEqual),l=o(n.areSetsEqual);n=P({},n,{areArraysEqual:c,areMapsEqual:i,areObjectsEqual:f,areSetsEqual:l})}return n}(r),p=function(r){var e=r.areArraysEqual,t=r.areDatesEqual,a=r.areMapsEqual,n=r.areObjectsEqual,u=r.arePrimitiveWrappersEqual,o=r.areRegExpsEqual,c=r.areSetsEqual,i=r.areTypedArraysEqual;return function(r,l,s){if(r===l)return!0;if(!r||!l||"object"!=typeof r||"object"!=typeof l)return r!=r&&l!=l;if(r.constructor===Object&&l.constructor===Object)return n(r,l,s);if(s.strict&&r.constructor!==l.constructor)return!1;var p=C(r),q=C(l);if(p||q)return p===q&&e(r,l,s);if(p=f(r),q=f(l),p||q)return p===q&&i(r,l,s);var b=T(r);return b===T(l)&&(b===$?t(r,l,s):b===D?o(r,l,s):b===S?a(r,l,s):b===M?c(r,l,s):b===z?"function"!=typeof r.then&&"function"!=typeof l.then&&n(r,l,s):b===O?n(r,l,s):(b===w||b===A||b===x)&&u(r,l,s))}}(s),q=a||(n?n(p):(e=p,function(r,t,a,n,u,o,c){return e(r,t,c)}));if(c)return function(r,e,a){var n=c(p),u=n.cache,o=void 0===u?t?new WeakMap:void 0:u,i=n.equals,f=void 0===i?q:i,s=n.meta,b=n.strict;return p(r,e,{cache:o,equals:f,meta:void 0!==a?a:s,strict:void 0===b?l:b})};if(t)return function(r,e){return p(r,e,{cache:new WeakMap,equals:q,meta:void 0,strict:l})};var B=Object.freeze({cache:void 0,equals:q,meta:void 0,strict:l});return function(r,e){return p(r,e,B)}}r.circularDeepEqual=k,r.circularShallowEqual=I,r.createCustomEqual=_,r.deepEqual=B,r.sameValueZeroEqual=l,r.shallowEqual=V,r.strictCircularDeepEqual=R,r.strictCircularShallowEqual=Z,r.strictDeepEqual=W,r.strictShallowEqual=N}));
|
|
@@ -2,7 +2,7 @@ import type { ComparatorConfig, CustomEqualCreatorOptions, EqualityComparator }
|
|
|
2
2
|
/**
|
|
3
3
|
* Create a comparator method based on the type-specific equality comparators passed.
|
|
4
4
|
*/
|
|
5
|
-
export declare function createComparator<Meta>({ areArraysEqual, areDatesEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
5
|
+
export declare function createComparator<Meta>({ areArraysEqual, areDatesEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
6
6
|
/**
|
|
7
7
|
* Create the configuration object used for building comparators.
|
|
8
8
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dictionary, State } from './internalTypes';
|
|
1
|
+
import type { Dictionary, State, TypedArray } from './internalTypes';
|
|
2
2
|
/**
|
|
3
3
|
* Whether the arrays are equal in value.
|
|
4
4
|
*/
|
|
@@ -31,3 +31,4 @@ export declare function areRegExpsEqual(a: RegExp, b: RegExp): boolean;
|
|
|
31
31
|
* Whether the `Set`s are equal in value.
|
|
32
32
|
*/
|
|
33
33
|
export declare function areSetsEqual(a: Set<any>, b: Set<any>, state: State<any>): boolean;
|
|
34
|
+
export declare function areTypedArraysEqual(a: TypedArray, b: TypedArray): boolean;
|
|
@@ -26,6 +26,7 @@ export interface ComparatorConfig<Meta> {
|
|
|
26
26
|
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
|
|
27
27
|
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
|
|
28
28
|
areSetsEqual: TypeEqualityComparator<any, Meta>;
|
|
29
|
+
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
29
30
|
}
|
|
30
31
|
export type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
|
|
31
32
|
export type CreateState<Meta> = (comparator: EqualityComparator<Meta>) => Partial<State<Meta>>;
|
|
@@ -33,6 +34,7 @@ export type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) =>
|
|
|
33
34
|
export type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
|
|
34
35
|
export type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
|
|
35
36
|
export type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
|
|
37
|
+
export type TypedArray = Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
|
|
36
38
|
export type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
|
|
37
39
|
export interface CustomEqualCreatorOptions<Meta> {
|
|
38
40
|
circular?: boolean;
|
|
@@ -23,6 +23,7 @@ export declare function getStrictProperties(object: Dictionary): Array<string |
|
|
|
23
23
|
* Whether the object contains the property passed as an own property.
|
|
24
24
|
*/
|
|
25
25
|
export declare const hasOwn: (o: object, v: PropertyKey) => boolean;
|
|
26
|
+
export declare function isArrayBuffer(value: any): value is ArrayBuffer;
|
|
26
27
|
/**
|
|
27
28
|
* Whether the values passed are strictly equal or both NaN.
|
|
28
29
|
*/
|
package/dist/umd/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
8
8
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
9
|
+
var SUPPORTS_ARRAY_BUFFER = typeof ArrayBuffer === 'function' && Boolean(ArrayBuffer.isView);
|
|
9
10
|
/**
|
|
10
11
|
* Combine two comparators into a single comparators.
|
|
11
12
|
*/
|
|
@@ -61,6 +62,9 @@
|
|
|
61
62
|
(function (object, property) {
|
|
62
63
|
return hasOwnProperty.call(object, property);
|
|
63
64
|
});
|
|
65
|
+
function isArrayBuffer(value) {
|
|
66
|
+
return SUPPORTS_ARRAY_BUFFER && ArrayBuffer.isView(value);
|
|
67
|
+
}
|
|
64
68
|
/**
|
|
65
69
|
* Whether the values passed are strictly equal or both NaN.
|
|
66
70
|
*/
|
|
@@ -239,6 +243,18 @@
|
|
|
239
243
|
}
|
|
240
244
|
return isValueEqual;
|
|
241
245
|
}
|
|
246
|
+
function areTypedArraysEqual(a, b) {
|
|
247
|
+
var index = a.length;
|
|
248
|
+
if (b.length !== index) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
while (index-- > 0) {
|
|
252
|
+
if (a[index] !== b[index]) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
242
258
|
|
|
243
259
|
var ARGUMENTS_TAG = '[object Arguments]';
|
|
244
260
|
var BOOLEAN_TAG = '[object Boolean]';
|
|
@@ -256,7 +272,7 @@
|
|
|
256
272
|
* Create a comparator method based on the type-specific equality comparators passed.
|
|
257
273
|
*/
|
|
258
274
|
function createComparator(_a) {
|
|
259
|
-
var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areMapsEqual = _a.areMapsEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual;
|
|
275
|
+
var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areMapsEqual = _a.areMapsEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, areTypedArraysEqual = _a.areTypedArraysEqual;
|
|
260
276
|
/**
|
|
261
277
|
* compare the value of the two objects and return true if they are equivalent in values
|
|
262
278
|
*/
|
|
@@ -286,6 +302,12 @@
|
|
|
286
302
|
if (a.constructor === Object && b.constructor === Object) {
|
|
287
303
|
return areObjectsEqual(a, b, state);
|
|
288
304
|
}
|
|
305
|
+
// In strict mode, constructors should match. We placed this after the plain object check
|
|
306
|
+
// because the constructors must match to meet plain object requirements (must both be `Object`
|
|
307
|
+
// in the given Realm), so it slightly improves performance on a very common use-case.
|
|
308
|
+
if (state.strict && a.constructor !== b.constructor) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
289
311
|
// `isArray()` works on subclasses and is cross-realm, so we can again avoid
|
|
290
312
|
// the `toString.call()` cost unless necessary by just checking if either
|
|
291
313
|
// and then both are arrays.
|
|
@@ -294,6 +316,11 @@
|
|
|
294
316
|
if (aArray || bArray) {
|
|
295
317
|
return aArray === bArray && areArraysEqual(a, b, state);
|
|
296
318
|
}
|
|
319
|
+
aArray = isArrayBuffer(a);
|
|
320
|
+
bArray = isArrayBuffer(b);
|
|
321
|
+
if (aArray || bArray) {
|
|
322
|
+
return aArray === bArray && areTypedArraysEqual(a, b, state);
|
|
323
|
+
}
|
|
297
324
|
// Since this is a custom object, use the classic `toString.call()` to get its
|
|
298
325
|
// type. This is reasonably performant in modern environments like v8 and
|
|
299
326
|
// SpiderMonkey, and allows for cross-realm comparison when other checks like
|
|
@@ -369,6 +396,9 @@
|
|
|
369
396
|
areSetsEqual: strict
|
|
370
397
|
? combineComparators(areSetsEqual, areObjectsEqualStrict)
|
|
371
398
|
: areSetsEqual,
|
|
399
|
+
areTypedArraysEqual: strict
|
|
400
|
+
? combineComparators(areTypedArraysEqual, areObjectsEqualStrict)
|
|
401
|
+
: areTypedArraysEqual,
|
|
372
402
|
};
|
|
373
403
|
if (createCustomConfig) {
|
|
374
404
|
config = assign({}, config, createCustomConfig(config));
|
package/dist/umd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils.ts","../../src/equals.ts","../../src/comparator.ts","../../src/index.ts"],"sourcesContent":["import {\n AnyEqualityComparator,\n BaseCircular,\n CircularState,\n Dictionary,\n EqualityComparator,\n InternalEqualityComparator,\n State,\n TypeEqualityComparator,\n} from './internalTypes';\n\nconst { getOwnPropertyNames, getOwnPropertySymbols } = Object;\nconst { hasOwnProperty } = Object.prototype;\n\n/**\n * Combine two comparators into a single comparators.\n */\nexport function combineComparators<Meta>(\n comparatorA: AnyEqualityComparator<Meta>,\n comparatorB: AnyEqualityComparator<Meta>,\n) {\n return function isEqual<A, B>(a: A, b: B, state: State<Meta>) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nexport function createInternalComparator<Meta>(\n compare: EqualityComparator<Meta>,\n): InternalEqualityComparator<Meta> {\n return function (\n a: any,\n b: any,\n _indexOrKeyA: any,\n _indexOrKeyB: any,\n _parentA: any,\n _parentB: any,\n state: State<Meta>,\n ) {\n return compare(a, b, state);\n };\n}\n\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nexport function createIsCircular<\n AreItemsEqual extends TypeEqualityComparator<any, any>,\n>(areItemsEqual: AreItemsEqual): AreItemsEqual {\n return function isCircular(\n a: any,\n b: any,\n state: CircularState<BaseCircular>,\n ) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n\n const { cache } = state;\n\n const cachedA = cache.get(a);\n const cachedB = cache.get(b);\n\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n\n cache.set(a, b);\n cache.set(b, a);\n\n const result = areItemsEqual(a, b, state);\n\n cache.delete(a);\n cache.delete(b);\n\n return result;\n } as AreItemsEqual;\n}\n\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nexport function getStrictProperties(\n object: Dictionary,\n): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object),\n );\n}\n\n/**\n * Whether the object contains the property passed as an own property.\n */\nexport const hasOwn =\n Object.hasOwn ||\n ((object: Dictionary, property: number | string | symbol) =>\n hasOwnProperty.call(object, property));\n\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nexport function sameValueZeroEqual(a: any, b: any): boolean {\n return a || b ? a === b : a === b || (a !== a && b !== b);\n}\n","import { getStrictProperties, hasOwn, sameValueZeroEqual } from './utils';\nimport type { Dictionary, State } from './internalTypes';\n\nconst OWNER = '_owner';\n\nconst { getOwnPropertyDescriptor, keys } = Object;\n\n/**\n * Whether the arrays are equal in value.\n */\nexport function areArraysEqual(a: any[], b: any[], state: State<any>) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the dates passed are equal in value.\n */\nexport function areDatesEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n\n/**\n * Whether the `Map`s are equal in value.\n */\nexport function areMapsEqual(\n a: Map<any, any>,\n b: Map<any, any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n let indexA = 0;\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndexB = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndexB] &&\n (hasMatch =\n state.equals(aKey, bKey, indexA, matchIndexB, a, b, state) &&\n state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndexB] = true;\n }\n\n matchIndexB++;\n });\n\n indexA++;\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\n/**\n * Whether the objects are equal in value.\n */\nexport function areObjectsEqual(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = keys(a);\n\n let index = properties.length;\n\n if (keys(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (\n !hasOwn(b, property) ||\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nexport function areObjectsEqualStrict(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = getStrictProperties(a);\n\n let index = properties.length;\n\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n let descriptorA: ReturnType<typeof getOwnPropertyDescriptor>;\n let descriptorB: ReturnType<typeof getOwnPropertyDescriptor>;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (!hasOwn(b, property)) {\n return false;\n }\n\n if (\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n\n if (\n (descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nexport function arePrimitiveWrappersEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n\n/**\n * Whether the regexps passed are equal in value.\n */\nexport function areRegExpsEqual(a: RegExp, b: RegExp): boolean {\n return a.source === b.source && a.flags === b.flags;\n}\n\n/**\n * Whether the `Set`s are equal in value.\n */\nexport function areSetsEqual(\n a: Set<any>,\n b: Set<any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndex = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndex] &&\n (hasMatch = state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndex] = true;\n }\n\n matchIndex++;\n });\n\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n","import {\n areArraysEqual as areArraysEqualDefault,\n areDatesEqual as areDatesEqualDefault,\n areMapsEqual as areMapsEqualDefault,\n areObjectsEqual as areObjectsEqualDefault,\n areObjectsEqualStrict as areObjectsEqualStrictDefault,\n arePrimitiveWrappersEqual as arePrimitiveWrappersEqualDefault,\n areRegExpsEqual as areRegExpsEqualDefault,\n areSetsEqual as areSetsEqualDefault,\n} from './equals';\nimport { combineComparators, createIsCircular } from './utils';\nimport type {\n ComparatorConfig,\n CustomEqualCreatorOptions,\n EqualityComparator,\n State,\n} from './internalTypes';\n\nconst ARGUMENTS_TAG = '[object Arguments]';\nconst BOOLEAN_TAG = '[object Boolean]';\nconst DATE_TAG = '[object Date]';\nconst MAP_TAG = '[object Map]';\nconst NUMBER_TAG = '[object Number]';\nconst OBJECT_TAG = '[object Object]';\nconst REG_EXP_TAG = '[object RegExp]';\nconst SET_TAG = '[object Set]';\nconst STRING_TAG = '[object String]';\n\nconst { isArray } = Array;\nconst { assign } = Object;\nconst getTag = Object.prototype.toString.call.bind(\n Object.prototype.toString,\n) as (a: object) => string;\n\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nexport function createComparator<Meta>({\n areArraysEqual,\n areDatesEqual,\n areMapsEqual,\n areObjectsEqual,\n arePrimitiveWrappersEqual,\n areRegExpsEqual,\n areSetsEqual,\n}: ComparatorConfig<Meta>): EqualityComparator<Meta> {\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a: any, b: any, state: State<Meta>): boolean {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n\n // If the items are not non-nullish objects, then the only possibility\n // of them being equal but not strictly is if they are both `NaN`. Since\n // `NaN` is uniquely not equal to itself, we can use self-comparison of\n // both objects, which is faster than `isNaN()`.\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return a !== a && b !== b;\n }\n\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid the `toString.call()` cost unless necessary.\n if (a.constructor === Object && b.constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n\n // `isArray()` works on subclasses and is cross-realm, so we can again avoid\n // the `toString.call()` cost unless necessary by just checking if either\n // and then both are arrays.\n const aArray = isArray(a);\n const bArray = isArray(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areArraysEqual(a, b, state);\n }\n\n // Since this is a custom object, use the classic `toString.call()` to get its\n // type. This is reasonably performant in modern environments like v8 and\n // SpiderMonkey, and allows for cross-realm comparison when other checks like\n // `instanceof` do not.\n const tag = getTag(a);\n\n if (tag !== getTag(b)) {\n return false;\n }\n\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n\n // If a simple object tag, then we can prioritize a simple object comparison because\n // it is likely a custom class.\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is `Promise`-like contracts. These should be\n // treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (\n typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state)\n );\n }\n\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n\n/**\n * Create the configuration object used for building comparators.\n */\nexport function createComparatorConfig<Meta>({\n circular,\n createCustomConfig,\n strict,\n}: CustomEqualCreatorOptions<Meta>): ComparatorConfig<Meta> {\n let config = {\n areArraysEqual: strict\n ? areObjectsEqualStrictDefault\n : areArraysEqualDefault,\n areDatesEqual: areDatesEqualDefault,\n areMapsEqual: strict\n ? combineComparators(areMapsEqualDefault, areObjectsEqualStrictDefault)\n : areMapsEqualDefault,\n areObjectsEqual: strict\n ? areObjectsEqualStrictDefault\n : areObjectsEqualDefault,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqualDefault,\n areRegExpsEqual: areRegExpsEqualDefault,\n areSetsEqual: strict\n ? combineComparators(areSetsEqualDefault, areObjectsEqualStrictDefault)\n : areSetsEqualDefault,\n };\n\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n\n if (circular) {\n const areArraysEqual = createIsCircular(config.areArraysEqual);\n const areMapsEqual = createIsCircular(config.areMapsEqual);\n const areObjectsEqual = createIsCircular(config.areObjectsEqual);\n const areSetsEqual = createIsCircular(config.areSetsEqual);\n\n config = assign({}, config, {\n areArraysEqual,\n areMapsEqual,\n areObjectsEqual,\n areSetsEqual,\n });\n }\n\n return config;\n}\n","import { createComparator, createComparatorConfig } from './comparator';\nimport type {\n CircularState,\n CustomEqualCreatorOptions,\n DefaultState,\n} from './internalTypes';\nimport { createInternalComparator, sameValueZeroEqual } from './utils';\n\nexport { sameValueZeroEqual };\nexport * from './internalTypes';\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nexport const deepEqual = createCustomEqual();\n\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nexport const strictDeepEqual = createCustomEqual({ strict: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nexport const circularDeepEqual = createCustomEqual({ circular: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nexport const shallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nexport const strictShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nexport const circularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n strict: true,\n});\n\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nexport function createCustomEqual<Meta>(\n options: CustomEqualCreatorOptions<Meta> = {},\n) {\n const {\n circular,\n comparator,\n createInternalComparator: createCustomInternalComparator,\n createState,\n strict: baseStrict = false,\n } = options;\n\n const config = createComparatorConfig<Meta>(options);\n const isEqualCustom = createComparator(config);\n const isEqualCustomComparator =\n comparator ||\n (createCustomInternalComparator\n ? createCustomInternalComparator(isEqualCustom)\n : createInternalComparator(isEqualCustom));\n\n if (createState) {\n return function isEqual<A, B>(\n a: A,\n b: B,\n metaOverride?: Meta | undefined,\n ): boolean {\n const {\n cache = circular ? new WeakMap() : undefined,\n equals = isEqualCustomComparator,\n meta,\n strict = baseStrict,\n } = createState!(isEqualCustom);\n\n return isEqualCustom(a, b, {\n cache,\n equals,\n meta: metaOverride !== undefined ? metaOverride : meta,\n strict,\n } as CircularState<Meta>);\n };\n }\n\n if (circular) {\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, {\n cache: new WeakMap(),\n equals: isEqualCustomComparator,\n meta: undefined as Meta,\n strict: baseStrict,\n } as CircularState<Meta>);\n };\n }\n\n const state = Object.freeze({\n cache: undefined,\n equals: isEqualCustomComparator,\n meta: undefined,\n strict: baseStrict,\n });\n\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, state as DefaultState<Meta>);\n };\n}\n"],"names":["areObjectsEqualStrictDefault","areArraysEqualDefault","areDatesEqualDefault","areMapsEqualDefault","areObjectsEqualDefault","arePrimitiveWrappersEqualDefault","areRegExpsEqualDefault","areSetsEqualDefault","areArraysEqual","areMapsEqual","areObjectsEqual","areSetsEqual"],"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,CAAC,EAAE,CAAC,EAAE;oBACzB,KAAK,EAAE,IAAI,OAAO,EAAE;IACpB,gBAAA,MAAM,EAAE,uBAAuB;IAC/B,gBAAA,IAAI,EAAE,SAAiB;IACvB,gBAAA,MAAM,EAAE,UAAU;IACI,aAAA,CAAC,CAAC;IAC5B,SAAC,CAAC;IACH,KAAA;IAED,IAAA,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1B,QAAA,KAAK,EAAE,SAAS;IAChB,QAAA,MAAM,EAAE,uBAAuB;IAC/B,QAAA,IAAI,EAAE,SAAS;IACf,QAAA,MAAM,EAAE,UAAU;IACnB,KAAA,CAAC,CAAC;IAEH,IAAA,OAAO,SAAS,MAAM,CAAO,CAAI,EAAE,CAAI,EAAA;YACrC,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,KAA2B,CAAC,CAAC;IAC1D,KAAC,CAAC;IACJ;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils.ts","../../src/equals.ts","../../src/comparator.ts","../../src/index.ts"],"sourcesContent":["import {\n AnyEqualityComparator,\n BaseCircular,\n CircularState,\n Dictionary,\n EqualityComparator,\n InternalEqualityComparator,\n State,\n TypeEqualityComparator,\n} from './internalTypes';\n\nconst { getOwnPropertyNames, getOwnPropertySymbols } = Object;\nconst { hasOwnProperty } = Object.prototype;\n\nconst SUPPORTS_ARRAY_BUFFER =\n typeof ArrayBuffer === 'function' && Boolean(ArrayBuffer.isView);\n\n/**\n * Combine two comparators into a single comparators.\n */\nexport function combineComparators<Meta>(\n comparatorA: AnyEqualityComparator<Meta>,\n comparatorB: AnyEqualityComparator<Meta>,\n) {\n return function isEqual<A, B>(a: A, b: B, state: State<Meta>) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nexport function createInternalComparator<Meta>(\n compare: EqualityComparator<Meta>,\n): InternalEqualityComparator<Meta> {\n return function (\n a: any,\n b: any,\n _indexOrKeyA: any,\n _indexOrKeyB: any,\n _parentA: any,\n _parentB: any,\n state: State<Meta>,\n ) {\n return compare(a, b, state);\n };\n}\n\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nexport function createIsCircular<\n AreItemsEqual extends TypeEqualityComparator<any, any>,\n>(areItemsEqual: AreItemsEqual): AreItemsEqual {\n return function isCircular(\n a: any,\n b: any,\n state: CircularState<BaseCircular>,\n ) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n\n const { cache } = state;\n\n const cachedA = cache.get(a);\n const cachedB = cache.get(b);\n\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n\n cache.set(a, b);\n cache.set(b, a);\n\n const result = areItemsEqual(a, b, state);\n\n cache.delete(a);\n cache.delete(b);\n\n return result;\n } as AreItemsEqual;\n}\n\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nexport function getStrictProperties(\n object: Dictionary,\n): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object),\n );\n}\n\n/**\n * Whether the object contains the property passed as an own property.\n */\nexport const hasOwn =\n Object.hasOwn ||\n ((object: Dictionary, property: number | string | symbol) =>\n hasOwnProperty.call(object, property));\n\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return SUPPORTS_ARRAY_BUFFER && ArrayBuffer.isView(value);\n}\n\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nexport function sameValueZeroEqual(a: any, b: any): boolean {\n return a || b ? a === b : a === b || (a !== a && b !== b);\n}\n","import { getStrictProperties, hasOwn, sameValueZeroEqual } from './utils';\nimport type { Dictionary, State, TypedArray } from './internalTypes';\n\nconst OWNER = '_owner';\n\nconst { getOwnPropertyDescriptor, keys } = Object;\n\n/**\n * Whether the arrays are equal in value.\n */\nexport function areArraysEqual(a: any[], b: any[], state: State<any>) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the dates passed are equal in value.\n */\nexport function areDatesEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n\n/**\n * Whether the `Map`s are equal in value.\n */\nexport function areMapsEqual(\n a: Map<any, any>,\n b: Map<any, any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n let indexA = 0;\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndexB = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndexB] &&\n (hasMatch =\n state.equals(aKey, bKey, indexA, matchIndexB, a, b, state) &&\n state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndexB] = true;\n }\n\n matchIndexB++;\n });\n\n indexA++;\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\n/**\n * Whether the objects are equal in value.\n */\nexport function areObjectsEqual(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = keys(a);\n\n let index = properties.length;\n\n if (keys(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (\n !hasOwn(b, property) ||\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nexport function areObjectsEqualStrict(\n a: Dictionary,\n b: Dictionary,\n state: State<any>,\n): boolean {\n const properties = getStrictProperties(a);\n\n let index = properties.length;\n\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n\n let property: string | symbol;\n let descriptorA: ReturnType<typeof getOwnPropertyDescriptor>;\n let descriptorB: ReturnType<typeof getOwnPropertyDescriptor>;\n\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index]!;\n\n if (\n property === OWNER &&\n (a.$$typeof || b.$$typeof) &&\n a.$$typeof !== b.$$typeof\n ) {\n return false;\n }\n\n if (!hasOwn(b, property)) {\n return false;\n }\n\n if (\n !state.equals(a[property], b[property], property, property, a, b, state)\n ) {\n return false;\n }\n\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n\n if (\n (descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nexport function arePrimitiveWrappersEqual(a: Date, b: Date): boolean {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n\n/**\n * Whether the regexps passed are equal in value.\n */\nexport function areRegExpsEqual(a: RegExp, b: RegExp): boolean {\n return a.source === b.source && a.flags === b.flags;\n}\n\n/**\n * Whether the `Set`s are equal in value.\n */\nexport function areSetsEqual(\n a: Set<any>,\n b: Set<any>,\n state: State<any>,\n): boolean {\n let isValueEqual = a.size === b.size;\n\n if (isValueEqual && a.size) {\n // The use of `forEach()` is to avoid the transpilation cost of `for...of` comparisons, and\n // the inability to control the performance of the resulting code. It also avoids excessive\n // iteration compared to doing comparisons of `keys()` and `values()`. As a result, though,\n // we cannot short-circuit the iterations; bookkeeping must be done to short-circuit the\n // equality checks themselves.\n\n const matchedIndices: Record<number, true> = {};\n\n a.forEach((aValue, aKey) => {\n if (!isValueEqual) {\n return;\n }\n\n let hasMatch = false;\n let matchIndex = 0;\n\n b.forEach((bValue, bKey) => {\n if (\n !hasMatch &&\n !matchedIndices[matchIndex] &&\n (hasMatch = state.equals(aValue, bValue, aKey, bKey, a, b, state))\n ) {\n matchedIndices[matchIndex] = true;\n }\n\n matchIndex++;\n });\n\n isValueEqual = hasMatch;\n });\n }\n\n return isValueEqual;\n}\n\nexport function areTypedArraysEqual(a: TypedArray, b: TypedArray) {\n let index = a.length;\n\n if (b.length !== index) {\n return false;\n }\n\n while (index-- > 0) {\n if (a[index] !== b[index]) {\n return false;\n }\n }\n\n return true;\n}\n","import {\n areArraysEqual as areArraysEqualDefault,\n areDatesEqual as areDatesEqualDefault,\n areMapsEqual as areMapsEqualDefault,\n areObjectsEqual as areObjectsEqualDefault,\n areObjectsEqualStrict as areObjectsEqualStrictDefault,\n arePrimitiveWrappersEqual as arePrimitiveWrappersEqualDefault,\n areRegExpsEqual as areRegExpsEqualDefault,\n areSetsEqual as areSetsEqualDefault,\n areTypedArraysEqual,\n} from './equals';\nimport { combineComparators, createIsCircular, isArrayBuffer } from './utils';\nimport type {\n ComparatorConfig,\n CustomEqualCreatorOptions,\n EqualityComparator,\n State,\n} from './internalTypes';\n\nconst ARGUMENTS_TAG = '[object Arguments]';\nconst BOOLEAN_TAG = '[object Boolean]';\nconst DATE_TAG = '[object Date]';\nconst MAP_TAG = '[object Map]';\nconst NUMBER_TAG = '[object Number]';\nconst OBJECT_TAG = '[object Object]';\nconst REG_EXP_TAG = '[object RegExp]';\nconst SET_TAG = '[object Set]';\nconst STRING_TAG = '[object String]';\n\nconst { isArray } = Array;\nconst { assign } = Object;\nconst getTag = Object.prototype.toString.call.bind(\n Object.prototype.toString,\n) as (a: object) => string;\n\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nexport function createComparator<Meta>({\n areArraysEqual,\n areDatesEqual,\n areMapsEqual,\n areObjectsEqual,\n arePrimitiveWrappersEqual,\n areRegExpsEqual,\n areSetsEqual,\n areTypedArraysEqual,\n}: ComparatorConfig<Meta>): EqualityComparator<Meta> {\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a: any, b: any, state: State<Meta>): boolean {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n\n // If the items are not non-nullish objects, then the only possibility\n // of them being equal but not strictly is if they are both `NaN`. Since\n // `NaN` is uniquely not equal to itself, we can use self-comparison of\n // both objects, which is faster than `isNaN()`.\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return a !== a && b !== b;\n }\n\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid the `toString.call()` cost unless necessary.\n if (a.constructor === Object && b.constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n\n // In strict mode, constructors should match. We placed this after the plain object check\n // because the constructors must match to meet plain object requirements (must both be `Object`\n // in the given Realm), so it slightly improves performance on a very common use-case.\n if (state.strict && a.constructor !== b.constructor) {\n return false;\n }\n\n // `isArray()` works on subclasses and is cross-realm, so we can again avoid\n // the `toString.call()` cost unless necessary by just checking if either\n // and then both are arrays.\n let aArray = isArray(a);\n let bArray = isArray(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areArraysEqual(a, b, state);\n }\n\n aArray = isArrayBuffer(a);\n bArray = isArrayBuffer(b);\n\n if (aArray || bArray) {\n return aArray === bArray && areTypedArraysEqual(a, b, state);\n }\n\n // Since this is a custom object, use the classic `toString.call()` to get its\n // type. This is reasonably performant in modern environments like v8 and\n // SpiderMonkey, and allows for cross-realm comparison when other checks like\n // `instanceof` do not.\n const tag = getTag(a);\n\n if (tag !== getTag(b)) {\n return false;\n }\n\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n\n // If a simple object tag, then we can prioritize a simple object comparison because\n // it is likely a custom class.\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is `Promise`-like contracts. These should be\n // treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (\n typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state)\n );\n }\n\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n\n/**\n * Create the configuration object used for building comparators.\n */\nexport function createComparatorConfig<Meta>({\n circular,\n createCustomConfig,\n strict,\n}: CustomEqualCreatorOptions<Meta>): ComparatorConfig<Meta> {\n let config = {\n areArraysEqual: strict\n ? areObjectsEqualStrictDefault\n : areArraysEqualDefault,\n areDatesEqual: areDatesEqualDefault,\n areMapsEqual: strict\n ? combineComparators(areMapsEqualDefault, areObjectsEqualStrictDefault)\n : areMapsEqualDefault,\n areObjectsEqual: strict\n ? areObjectsEqualStrictDefault\n : areObjectsEqualDefault,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqualDefault,\n areRegExpsEqual: areRegExpsEqualDefault,\n areSetsEqual: strict\n ? combineComparators(areSetsEqualDefault, areObjectsEqualStrictDefault)\n : areSetsEqualDefault,\n areTypedArraysEqual: strict\n ? combineComparators(areTypedArraysEqual, areObjectsEqualStrictDefault)\n : areTypedArraysEqual,\n };\n\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n\n if (circular) {\n const areArraysEqual = createIsCircular(config.areArraysEqual);\n const areMapsEqual = createIsCircular(config.areMapsEqual);\n const areObjectsEqual = createIsCircular(config.areObjectsEqual);\n const areSetsEqual = createIsCircular(config.areSetsEqual);\n\n config = assign({}, config, {\n areArraysEqual,\n areMapsEqual,\n areObjectsEqual,\n areSetsEqual,\n });\n }\n\n return config;\n}\n","import { createComparator, createComparatorConfig } from './comparator';\nimport type {\n CircularState,\n CustomEqualCreatorOptions,\n DefaultState,\n} from './internalTypes';\nimport { createInternalComparator, sameValueZeroEqual } from './utils';\n\nexport { sameValueZeroEqual };\nexport * from './internalTypes';\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nexport const deepEqual = createCustomEqual();\n\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nexport const strictDeepEqual = createCustomEqual({ strict: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nexport const circularDeepEqual = createCustomEqual({ circular: true });\n\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nexport const shallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nexport const strictShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n strict: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nexport const circularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n});\n\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nexport const strictCircularShallowEqual = createCustomEqual({\n comparator: sameValueZeroEqual,\n circular: true,\n strict: true,\n});\n\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nexport function createCustomEqual<Meta>(\n options: CustomEqualCreatorOptions<Meta> = {},\n) {\n const {\n circular,\n comparator,\n createInternalComparator: createCustomInternalComparator,\n createState,\n strict: baseStrict = false,\n } = options;\n\n const config = createComparatorConfig<Meta>(options);\n const isEqualCustom = createComparator(config);\n const isEqualCustomComparator =\n comparator ||\n (createCustomInternalComparator\n ? createCustomInternalComparator(isEqualCustom)\n : createInternalComparator(isEqualCustom));\n\n if (createState) {\n return function isEqual<A, B>(\n a: A,\n b: B,\n metaOverride?: Meta | undefined,\n ): boolean {\n const {\n cache = circular ? new WeakMap() : undefined,\n equals = isEqualCustomComparator,\n meta,\n strict = baseStrict,\n } = createState!(isEqualCustom);\n\n return isEqualCustom(a, b, {\n cache,\n equals,\n meta: metaOverride !== undefined ? metaOverride : meta,\n strict,\n } as CircularState<Meta>);\n };\n }\n\n if (circular) {\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, {\n cache: new WeakMap(),\n equals: isEqualCustomComparator,\n meta: undefined as Meta,\n strict: baseStrict,\n } as CircularState<Meta>);\n };\n }\n\n const state = Object.freeze({\n cache: undefined,\n equals: isEqualCustomComparator,\n meta: undefined,\n strict: baseStrict,\n });\n\n return function equals<A, B>(a: A, b: B): boolean {\n return isEqualCustom(a, b, state as DefaultState<Meta>);\n };\n}\n"],"names":["areObjectsEqualStrictDefault","areArraysEqualDefault","areDatesEqualDefault","areMapsEqualDefault","areObjectsEqualDefault","arePrimitiveWrappersEqualDefault","areRegExpsEqualDefault","areSetsEqualDefault","areArraysEqual","areMapsEqual","areObjectsEqual","areSetsEqual"],"mappings":";;;;;;IAWQ,IAAA,mBAAmB,GAA4B,MAAM,CAAA,mBAAlC,EAAE,qBAAqB,GAAK,MAAM,CAAA,qBAAX,CAAY;IACtD,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;IAE5C,IAAM,qBAAqB,GACzB,OAAO,WAAW,KAAK,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAEnE;;IAEG;IACa,SAAA,kBAAkB,CAChC,WAAwC,EACxC,WAAwC,EAAA;IAExC,IAAA,OAAO,SAAS,OAAO,CAAO,CAAI,EAAE,CAAI,EAAE,KAAkB,EAAA;IAC1D,QAAA,OAAO,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9D,KAAC,CAAC;IACJ,CAAC;IAED;;;IAGG;IACG,SAAU,wBAAwB,CACtC,OAAiC,EAAA;IAEjC,IAAA,OAAO,UACL,CAAM,EACN,CAAM,EACN,YA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based on the type-specific equality comparators passed.
|
|
4
4
|
*/
|
|
5
|
-
export declare function createComparator<Meta>({ areArraysEqual, areDatesEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
5
|
+
export declare function createComparator<Meta>({ areArraysEqual, areDatesEqual, areMapsEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
6
6
|
/**
|
|
7
7
|
* Create the configuration object used for building comparators.
|
|
8
8
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dictionary, State } from './internalTypes';
|
|
1
|
+
import type { Dictionary, State, TypedArray } from './internalTypes';
|
|
2
2
|
/**
|
|
3
3
|
* Whether the arrays are equal in value.
|
|
4
4
|
*/
|
|
@@ -31,3 +31,4 @@ export declare function areRegExpsEqual(a: RegExp, b: RegExp): boolean;
|
|
|
31
31
|
* Whether the `Set`s are equal in value.
|
|
32
32
|
*/
|
|
33
33
|
export declare function areSetsEqual(a: Set<any>, b: Set<any>, state: State<any>): boolean;
|
|
34
|
+
export declare function areTypedArraysEqual(a: TypedArray, b: TypedArray): boolean;
|
|
@@ -26,6 +26,7 @@ export interface ComparatorConfig<Meta> {
|
|
|
26
26
|
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
|
|
27
27
|
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
|
|
28
28
|
areSetsEqual: TypeEqualityComparator<any, Meta>;
|
|
29
|
+
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
29
30
|
}
|
|
30
31
|
export type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
|
|
31
32
|
export type CreateState<Meta> = (comparator: EqualityComparator<Meta>) => Partial<State<Meta>>;
|
|
@@ -33,6 +34,7 @@ export type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) =>
|
|
|
33
34
|
export type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
|
|
34
35
|
export type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
|
|
35
36
|
export type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
|
|
37
|
+
export type TypedArray = Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
|
|
36
38
|
export type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
|
|
37
39
|
export interface CustomEqualCreatorOptions<Meta> {
|
|
38
40
|
circular?: boolean;
|
|
@@ -23,6 +23,7 @@ export declare function getStrictProperties(object: Dictionary): Array<string |
|
|
|
23
23
|
* Whether the object contains the property passed as an own property.
|
|
24
24
|
*/
|
|
25
25
|
export declare const hasOwn: (o: object, v: PropertyKey) => boolean;
|
|
26
|
+
export declare function isArrayBuffer(value: any): value is ArrayBuffer;
|
|
26
27
|
/**
|
|
27
28
|
* Whether the values passed are strictly equal or both NaN.
|
|
28
29
|
*/
|
package/package.json
CHANGED
|
@@ -49,6 +49,9 @@
|
|
|
49
49
|
"webpack-cli": "^5.0.1",
|
|
50
50
|
"webpack-dev-server": "^4.11.1"
|
|
51
51
|
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=6.0.0"
|
|
54
|
+
},
|
|
52
55
|
"exports": {
|
|
53
56
|
".": {
|
|
54
57
|
"import": {
|
|
@@ -106,5 +109,5 @@
|
|
|
106
109
|
"sideEffects": false,
|
|
107
110
|
"type": "module",
|
|
108
111
|
"types": "./index.d.ts",
|
|
109
|
-
"version": "5.0.0-beta.
|
|
112
|
+
"version": "5.0.0-beta.4"
|
|
110
113
|
}
|
package/src/comparator.ts
CHANGED
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
arePrimitiveWrappersEqual as arePrimitiveWrappersEqualDefault,
|
|
8
8
|
areRegExpsEqual as areRegExpsEqualDefault,
|
|
9
9
|
areSetsEqual as areSetsEqualDefault,
|
|
10
|
+
areTypedArraysEqual,
|
|
10
11
|
} from './equals';
|
|
11
|
-
import { combineComparators, createIsCircular } from './utils';
|
|
12
|
+
import { combineComparators, createIsCircular, isArrayBuffer } from './utils';
|
|
12
13
|
import type {
|
|
13
14
|
ComparatorConfig,
|
|
14
15
|
CustomEqualCreatorOptions,
|
|
@@ -43,6 +44,7 @@ export function createComparator<Meta>({
|
|
|
43
44
|
arePrimitiveWrappersEqual,
|
|
44
45
|
areRegExpsEqual,
|
|
45
46
|
areSetsEqual,
|
|
47
|
+
areTypedArraysEqual,
|
|
46
48
|
}: ComparatorConfig<Meta>): EqualityComparator<Meta> {
|
|
47
49
|
/**
|
|
48
50
|
* compare the value of the two objects and return true if they are equivalent in values
|
|
@@ -77,16 +79,30 @@ export function createComparator<Meta>({
|
|
|
77
79
|
return areObjectsEqual(a, b, state);
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
// In strict mode, constructors should match. We placed this after the plain object check
|
|
83
|
+
// because the constructors must match to meet plain object requirements (must both be `Object`
|
|
84
|
+
// in the given Realm), so it slightly improves performance on a very common use-case.
|
|
85
|
+
if (state.strict && a.constructor !== b.constructor) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
80
89
|
// `isArray()` works on subclasses and is cross-realm, so we can again avoid
|
|
81
90
|
// the `toString.call()` cost unless necessary by just checking if either
|
|
82
91
|
// and then both are arrays.
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
let aArray = isArray(a);
|
|
93
|
+
let bArray = isArray(b);
|
|
85
94
|
|
|
86
95
|
if (aArray || bArray) {
|
|
87
96
|
return aArray === bArray && areArraysEqual(a, b, state);
|
|
88
97
|
}
|
|
89
98
|
|
|
99
|
+
aArray = isArrayBuffer(a);
|
|
100
|
+
bArray = isArrayBuffer(b);
|
|
101
|
+
|
|
102
|
+
if (aArray || bArray) {
|
|
103
|
+
return aArray === bArray && areTypedArraysEqual(a, b, state);
|
|
104
|
+
}
|
|
105
|
+
|
|
90
106
|
// Since this is a custom object, use the classic `toString.call()` to get its
|
|
91
107
|
// type. This is reasonably performant in modern environments like v8 and
|
|
92
108
|
// SpiderMonkey, and allows for cross-realm comparison when other checks like
|
|
@@ -177,6 +193,9 @@ export function createComparatorConfig<Meta>({
|
|
|
177
193
|
areSetsEqual: strict
|
|
178
194
|
? combineComparators(areSetsEqualDefault, areObjectsEqualStrictDefault)
|
|
179
195
|
: areSetsEqualDefault,
|
|
196
|
+
areTypedArraysEqual: strict
|
|
197
|
+
? combineComparators(areTypedArraysEqual, areObjectsEqualStrictDefault)
|
|
198
|
+
: areTypedArraysEqual,
|
|
180
199
|
};
|
|
181
200
|
|
|
182
201
|
if (createCustomConfig) {
|
package/src/equals.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getStrictProperties, hasOwn, sameValueZeroEqual } from './utils';
|
|
2
|
-
import type { Dictionary, State } from './internalTypes';
|
|
2
|
+
import type { Dictionary, State, TypedArray } from './internalTypes';
|
|
3
3
|
|
|
4
4
|
const OWNER = '_owner';
|
|
5
5
|
|
|
@@ -248,3 +248,19 @@ export function areSetsEqual(
|
|
|
248
248
|
|
|
249
249
|
return isValueEqual;
|
|
250
250
|
}
|
|
251
|
+
|
|
252
|
+
export function areTypedArraysEqual(a: TypedArray, b: TypedArray) {
|
|
253
|
+
let index = a.length;
|
|
254
|
+
|
|
255
|
+
if (b.length !== index) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
while (index-- > 0) {
|
|
260
|
+
if (a[index] !== b[index]) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return true;
|
|
266
|
+
}
|
package/src/internalTypes.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface ComparatorConfig<Meta> {
|
|
|
32
32
|
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
|
|
33
33
|
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
|
|
34
34
|
areSetsEqual: TypeEqualityComparator<any, Meta>;
|
|
35
|
+
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export type CreateCustomComparatorConfig<Meta> = (
|
|
@@ -67,6 +68,17 @@ export type InternalEqualityComparator<Meta> = (
|
|
|
67
68
|
state: State<Meta>,
|
|
68
69
|
) => boolean;
|
|
69
70
|
|
|
71
|
+
export type TypedArray =
|
|
72
|
+
| Float32Array
|
|
73
|
+
| Float64Array
|
|
74
|
+
| Int8Array
|
|
75
|
+
| Int16Array
|
|
76
|
+
| Int32Array
|
|
77
|
+
| Uint16Array
|
|
78
|
+
| Uint32Array
|
|
79
|
+
| Uint8Array
|
|
80
|
+
| Uint8ClampedArray;
|
|
81
|
+
|
|
70
82
|
export type TypeEqualityComparator<Type, Meta = undefined> = (
|
|
71
83
|
a: Type,
|
|
72
84
|
b: Type,
|
package/src/utils.ts
CHANGED
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
13
13
|
const { hasOwnProperty } = Object.prototype;
|
|
14
14
|
|
|
15
|
+
const SUPPORTS_ARRAY_BUFFER =
|
|
16
|
+
typeof ArrayBuffer === 'function' && Boolean(ArrayBuffer.isView);
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* Combine two comparators into a single comparators.
|
|
17
20
|
*/
|
|
@@ -102,6 +105,10 @@ export const hasOwn =
|
|
|
102
105
|
((object: Dictionary, property: number | string | symbol) =>
|
|
103
106
|
hasOwnProperty.call(object, property));
|
|
104
107
|
|
|
108
|
+
export function isArrayBuffer(value: any): value is ArrayBuffer {
|
|
109
|
+
return SUPPORTS_ARRAY_BUFFER && ArrayBuffer.isView(value);
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
/**
|
|
106
113
|
* Whether the values passed are strictly equal or both NaN.
|
|
107
114
|
*/
|