fast-equals 5.3.3 → 5.3.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/LICENSE +1 -1
- package/README.md +127 -76
- package/dist/cjs/comparator.d.cts +58 -0
- package/dist/cjs/index.cjs +132 -155
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/{types/index.d.cts → index.d.cts} +21 -2
- package/{src/internalTypes.ts → dist/cjs/internalTypes.d.cts} +7 -43
- package/dist/cjs/{types/utils.d.cts → utils.d.cts} +7 -2
- package/dist/es/comparator.d.mts +58 -0
- package/dist/{esm/types → es}/index.d.mts +21 -2
- package/dist/{esm → es}/index.mjs +132 -155
- package/dist/es/index.mjs.map +1 -0
- package/dist/es/internalTypes.d.mts +174 -0
- package/dist/{esm/types → es}/utils.d.mts +7 -2
- package/dist/{min/types → umd}/comparator.d.ts +1 -1
- package/dist/umd/index.js +132 -155
- package/dist/umd/index.js.map +1 -1
- package/index.d.ts +62 -68
- package/package.json +44 -47
- package/CHANGELOG.md +0 -364
- package/dist/cjs/types/comparator.d.cts +0 -26
- package/dist/cjs/types/internalTypes.d.cts +0 -157
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/types/comparator.d.mts +0 -26
- package/dist/esm/types/internalTypes.d.mts +0 -157
- package/dist/min/index.js +0 -1
- package/dist/umd/types/comparator.d.ts +0 -26
- package/dist/umd/types/equals.d.ts +0 -54
- package/dist/umd/types/index.d.ts +0 -47
- package/dist/umd/types/internalTypes.d.ts +0 -157
- package/dist/umd/types/utils.d.ts +0 -28
- package/src/comparator.ts +0 -376
- package/src/equals.ts +0 -355
- package/src/index.ts +0 -112
- package/src/utils.ts +0 -96
- /package/dist/cjs/{types/equals.d.cts → equals.d.cts} +0 -0
- /package/dist/{esm/types → es}/equals.d.mts +0 -0
- /package/dist/{min/types → umd}/equals.d.ts +0 -0
- /package/dist/{min/types → umd}/index.d.ts +0 -0
- /package/dist/{min/types → umd}/internalTypes.d.ts +0 -0
- /package/dist/{min/types → umd}/utils.d.ts +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ComparatorConfig, CreateState, CustomEqualCreatorOptions, EqualityComparator, InternalEqualityComparator } from './internalTypes.d.mts';
|
|
2
|
-
interface CreateIsEqualOptions<Meta> {
|
|
3
|
-
circular: boolean;
|
|
4
|
-
comparator: EqualityComparator<Meta>;
|
|
5
|
-
createState: CreateState<Meta> | undefined;
|
|
6
|
-
equals: InternalEqualityComparator<Meta>;
|
|
7
|
-
strict: boolean;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Create a comparator method based on the type-specific equality comparators passed.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createEqualityComparator<Meta>({ areArraysEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, unknownTagComparators, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
13
|
-
/**
|
|
14
|
-
* Create the configuration object used for building comparators.
|
|
15
|
-
*/
|
|
16
|
-
export declare function createEqualityComparatorConfig<Meta>({ circular, createCustomConfig, strict, }: CustomEqualCreatorOptions<Meta>): ComparatorConfig<Meta>;
|
|
17
|
-
/**
|
|
18
|
-
* Default equality comparator pass-through, used as the standard `isEqual` creator for
|
|
19
|
-
* use inside the built comparator.
|
|
20
|
-
*/
|
|
21
|
-
export declare function createInternalEqualityComparator<Meta>(compare: EqualityComparator<Meta>): InternalEqualityComparator<Meta>;
|
|
22
|
-
/**
|
|
23
|
-
* Create the `isEqual` function used by the consuming application.
|
|
24
|
-
*/
|
|
25
|
-
export declare function createIsEqual<Meta>({ circular, comparator, createState, equals, strict, }: CreateIsEqualOptions<Meta>): <A, B>(a: A, b: B) => boolean;
|
|
26
|
-
export {};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache used to store references to objects, used for circular
|
|
3
|
-
* reference checks.
|
|
4
|
-
*/
|
|
5
|
-
export interface Cache<Key extends object, Value> {
|
|
6
|
-
delete(key: Key): boolean;
|
|
7
|
-
get(key: Key): Value | undefined;
|
|
8
|
-
set(key: Key, value: any): any;
|
|
9
|
-
}
|
|
10
|
-
export interface State<Meta> {
|
|
11
|
-
/**
|
|
12
|
-
* Cache used to identify circular references
|
|
13
|
-
*/
|
|
14
|
-
readonly cache: Cache<any, any> | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Method used to determine equality of nested value.
|
|
17
|
-
*/
|
|
18
|
-
readonly equals: InternalEqualityComparator<Meta>;
|
|
19
|
-
/**
|
|
20
|
-
* Additional value that can be used for comparisons.
|
|
21
|
-
*/
|
|
22
|
-
meta: Meta;
|
|
23
|
-
/**
|
|
24
|
-
* Whether the equality comparison is strict, meaning it matches
|
|
25
|
-
* all properties (including symbols and non-enumerable properties)
|
|
26
|
-
* with equal shape of descriptors.
|
|
27
|
-
*/
|
|
28
|
-
readonly strict: boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface CircularState<Meta> extends State<Meta> {
|
|
31
|
-
readonly cache: Cache<any, any>;
|
|
32
|
-
}
|
|
33
|
-
export interface DefaultState<Meta> extends State<Meta> {
|
|
34
|
-
readonly cache: undefined;
|
|
35
|
-
}
|
|
36
|
-
export interface Dictionary<Value = any> {
|
|
37
|
-
[key: string | symbol]: Value;
|
|
38
|
-
$$typeof?: any;
|
|
39
|
-
}
|
|
40
|
-
export interface ComparatorConfig<Meta> {
|
|
41
|
-
/**
|
|
42
|
-
* Whether the arrays passed are equal in value. In strict mode, this includes
|
|
43
|
-
* additional properties added to the array.
|
|
44
|
-
*/
|
|
45
|
-
areArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
46
|
-
/**
|
|
47
|
-
* Whether the dates passed are equal in value.
|
|
48
|
-
*/
|
|
49
|
-
areDatesEqual: TypeEqualityComparator<any, Meta>;
|
|
50
|
-
/**
|
|
51
|
-
* Whether the errors passed are equal in value.
|
|
52
|
-
*/
|
|
53
|
-
areErrorsEqual: TypeEqualityComparator<any, Meta>;
|
|
54
|
-
/**
|
|
55
|
-
* Whether the functions passed are equal in value.
|
|
56
|
-
*/
|
|
57
|
-
areFunctionsEqual: TypeEqualityComparator<any, Meta>;
|
|
58
|
-
/**
|
|
59
|
-
* Whether the maps passed are equal in value. In strict mode, this includes
|
|
60
|
-
* additional properties added to the map.
|
|
61
|
-
*/
|
|
62
|
-
areMapsEqual: TypeEqualityComparator<any, Meta>;
|
|
63
|
-
/**
|
|
64
|
-
* Whether the numbers passed are equal in value.
|
|
65
|
-
*/
|
|
66
|
-
areNumbersEqual: TypeEqualityComparator<any, Meta>;
|
|
67
|
-
/**
|
|
68
|
-
* Whether the objects passed are equal in value. In strict mode, this includes
|
|
69
|
-
* non-enumerable properties added to the map, as well as symbol properties.
|
|
70
|
-
*/
|
|
71
|
-
areObjectsEqual: TypeEqualityComparator<any, Meta>;
|
|
72
|
-
/**
|
|
73
|
-
* Whether the primitive wrappers passed are equal in value.
|
|
74
|
-
*/
|
|
75
|
-
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
|
|
76
|
-
/**
|
|
77
|
-
* Whether the regexps passed are equal in value.
|
|
78
|
-
*/
|
|
79
|
-
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
|
|
80
|
-
/**
|
|
81
|
-
* Whether the sets passed are equal in value. In strict mode, this includes
|
|
82
|
-
* additional properties added to the set.
|
|
83
|
-
*/
|
|
84
|
-
areSetsEqual: TypeEqualityComparator<any, Meta>;
|
|
85
|
-
/**
|
|
86
|
-
* Whether the typed arrays passed are equal in value. In strict mode, this includes
|
|
87
|
-
* additional properties added to the typed array.
|
|
88
|
-
*/
|
|
89
|
-
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
90
|
-
/**
|
|
91
|
-
* Whether the URLs passed are equal in value.
|
|
92
|
-
*/
|
|
93
|
-
areUrlsEqual: TypeEqualityComparator<any, Meta>;
|
|
94
|
-
/**
|
|
95
|
-
* Whether two values with unknown `@@toStringTag` are equal in value. This comparator is
|
|
96
|
-
* called when no other comparator applies.
|
|
97
|
-
*
|
|
98
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag
|
|
99
|
-
*/
|
|
100
|
-
unknownTagComparators: Record<string, TypeEqualityComparator<any, Meta>> | undefined;
|
|
101
|
-
}
|
|
102
|
-
export type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
|
|
103
|
-
export type CreateState<Meta> = () => {
|
|
104
|
-
cache?: Cache<any, any> | undefined;
|
|
105
|
-
meta?: Meta;
|
|
106
|
-
};
|
|
107
|
-
export type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) => boolean;
|
|
108
|
-
export type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
|
|
109
|
-
export type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
|
|
110
|
-
export type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
|
|
111
|
-
export type PrimitiveWrapper = Boolean | Number | String;
|
|
112
|
-
/**
|
|
113
|
-
* Type which encompasses possible instances of TypedArray
|
|
114
|
-
* classes.
|
|
115
|
-
*
|
|
116
|
-
* **NOTE**: This does not include `BigInt64Array` and
|
|
117
|
-
* `BitUint64Array` because those are part of ES2020 and
|
|
118
|
-
* not supported by certain TS configurations. If using
|
|
119
|
-
* either in `areTypedArraysEqual`, you can cast the
|
|
120
|
-
* instance as `TypedArray` and it will work as expected,
|
|
121
|
-
* because runtime checks will still work for those classes.
|
|
122
|
-
*/
|
|
123
|
-
export type TypedArray = Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
|
|
124
|
-
export type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
|
|
125
|
-
export interface CustomEqualCreatorOptions<Meta> {
|
|
126
|
-
/**
|
|
127
|
-
* Whether circular references should be supported. It causes the
|
|
128
|
-
* comparison to be slower, but for objects that have circular references
|
|
129
|
-
* it is required to avoid stack overflows.
|
|
130
|
-
*/
|
|
131
|
-
circular?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Create a custom configuration of type-specific equality comparators.
|
|
134
|
-
* This receives the default configuration, which allows either replacement
|
|
135
|
-
* or supersetting of the default methods.
|
|
136
|
-
*/
|
|
137
|
-
createCustomConfig?: CreateCustomComparatorConfig<Meta>;
|
|
138
|
-
/**
|
|
139
|
-
* Create a custom internal comparator, which is used as an override to the
|
|
140
|
-
* default entry point for nested value equality comparisons. This is often
|
|
141
|
-
* used for doing custom logic for specific types (such as handling a specific
|
|
142
|
-
* class instance differently than other objects) or to incorporate `meta` in
|
|
143
|
-
* the comparison. See the recipes for examples.
|
|
144
|
-
*/
|
|
145
|
-
createInternalComparator?: (compare: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
|
|
146
|
-
/**
|
|
147
|
-
* Create a custom `state` object passed between the methods. This allows for
|
|
148
|
-
* custom `cache` and/or `meta` values to be used.
|
|
149
|
-
*/
|
|
150
|
-
createState?: CreateState<Meta>;
|
|
151
|
-
/**
|
|
152
|
-
* Whether the equality comparison is strict, meaning it matches
|
|
153
|
-
* all properties (including symbols and non-enumerable properties)
|
|
154
|
-
* with equal shape of descriptors.
|
|
155
|
-
*/
|
|
156
|
-
strict?: boolean;
|
|
157
|
-
}
|
package/dist/min/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;function n(r,e){return function(t,a,n){return r(t,a,n)&&e(t,a,n)}}function u(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 i=r(e,t,a);return n.delete(e),n.delete(t),i}}function o(r){return e(r).concat(t(r))}var i=Object.hasOwn||function(r,e){return a.call(r,e)};function c(r,e){return r===e||!r&&!e&&r!=r&&e!=e}var l=Object.getOwnPropertyDescriptor,f=Object.keys;function s(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 p(r,e){return c(r.getTime(),e.getTime())}function v(r,e){return r.name===e.name&&r.message===e.message&&r.cause===e.cause&&r.stack===e.stack}function q(r,e){return r===e}function E(r,e,t){var a=r.size;if(a!==e.size)return!1;if(!a)return!0;for(var n,u,o=new Array(a),i=r.entries(),c=0;(n=i.next())&&!n.done;){for(var l=e.entries(),f=!1,s=0;(u=l.next())&&!u.done;)if(o[s])s++;else{var p=n.value,v=u.value;if(t.equals(p[0],v[0],c,s,r,e,t)&&t.equals(p[1],v[1],p[0],v[0],r,e,t)){f=o[s]=!0;break}s++}if(!f)return!1;c++}return!0}var b=c;function m(r,e,t){var a=f(r),n=a.length;if(f(e).length!==n)return!1;for(;n-- >0;)if(!O(r,e,t,a[n]))return!1;return!0}function y(r,e,t){var a,n,u,i=o(r),c=i.length;if(o(e).length!==c)return!1;for(;c-- >0;){if(!O(r,e,t,a=i[c]))return!1;if(n=l(r,a),u=l(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 c(r.valueOf(),e.valueOf())}function d(r,e){return r.source===e.source&&r.flags===e.flags}function h(r,e,t){var a=r.size;if(a!==e.size)return!1;if(!a)return!0;for(var n,u,o=new Array(a),i=r.values();(n=i.next())&&!n.done;){for(var c=e.values(),l=!1,f=0;(u=c.next())&&!u.done;){if(!o[f]&&t.equals(n.value,u.value,n.value,u.value,r,e,t)){l=o[f]=!0;break}f++}if(!l)return!1}return!0}function j(r,e){var t=r.length;if(e.length!==t)return!1;for(;t-- >0;)if(r[t]!==e[t])return!1;return!0}function w(r,e){return r.hostname===e.hostname&&r.pathname===e.pathname&&r.protocol===e.protocol&&r.port===e.port&&r.hash===e.hash&&r.username===e.username&&r.password===e.password}function O(r,e,t,a){return!("_owner"!==a&&"__o"!==a&&"__v"!==a||!r.$$typeof&&!e.$$typeof)||i(e,a)&&t.equals(r[a],e[a],a,a,r,e,t)}var S=Array.isArray,A="undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView:null,C=Object.assign,x=Object.prototype.toString.call.bind(Object.prototype.toString);function k(r){var e=r.areArraysEqual,t=r.areDatesEqual,a=r.areErrorsEqual,n=r.areFunctionsEqual,u=r.areMapsEqual,o=r.areNumbersEqual,i=r.areObjectsEqual,c=r.arePrimitiveWrappersEqual,l=r.areRegExpsEqual,f=r.areSetsEqual,s=r.areTypedArraysEqual,p=r.areUrlsEqual,v=r.unknownTagComparators;return function(r,q,E){if(r===q)return!0;if(null==r||null==q)return!1;var b=typeof r;if(b!==typeof q)return!1;if("object"!==b)return"number"===b?o(r,q,E):"function"===b&&n(r,q,E);var m=r.constructor;if(m!==q.constructor)return!1;if(m===Object)return i(r,q,E);if(S(r))return e(r,q,E);if(null!=A&&A(r))return s(r,q,E);if(m===Date)return t(r,q,E);if(m===RegExp)return l(r,q,E);if(m===Map)return u(r,q,E);if(m===Set)return f(r,q,E);var y,g=x(r);if("[object Date]"===g)return t(r,q,E);if("[object RegExp]"===g)return l(r,q,E);if("[object Map]"===g)return u(r,q,E);if("[object Set]"===g)return f(r,q,E);if("[object Object]"===g)return"function"!=typeof r.then&&"function"!=typeof q.then&&i(r,q,E);if("[object URL]"===g)return p(r,q,E);if("[object Error]"===g)return a(r,q,E);if("[object Arguments]"===g)return i(r,q,E);if("[object Boolean]"===g||"[object Number]"===g||"[object String]"===g)return c(r,q,E);if(v){var d=v[g];if(!d){var h=null!=(y=r)?y[Symbol.toStringTag]:void 0;h&&(d=v[h])}if(d)return d(r,q,E)}return!1}}var T=B(),D=B({strict:!0}),M=B({circular:!0}),P=B({circular:!0,strict:!0}),I=B({createInternalComparator:function(){return c}}),R=B({strict:!0,createInternalComparator:function(){return c}}),_=B({circular:!0,createInternalComparator:function(){return c}}),z=B({circular:!0,createInternalComparator:function(){return c},strict:!0});function B(r){void 0===r&&(r={});var e,t=r.circular,a=void 0!==t&&t,o=r.createInternalComparator,i=r.createState,c=r.strict,l=void 0!==c&&c,f=function(r){var e=r.circular,t=r.createCustomConfig,a=r.strict,o={areArraysEqual:a?y:s,areDatesEqual:p,areErrorsEqual:v,areFunctionsEqual:q,areMapsEqual:a?n(E,y):E,areNumbersEqual:b,areObjectsEqual:a?y:m,arePrimitiveWrappersEqual:g,areRegExpsEqual:d,areSetsEqual:a?n(h,y):h,areTypedArraysEqual:a?y:j,areUrlsEqual:w,unknownTagComparators:void 0};if(t&&(o=C({},o,t(o))),e){var i=u(o.areArraysEqual),c=u(o.areMapsEqual),l=u(o.areObjectsEqual),f=u(o.areSetsEqual);o=C({},o,{areArraysEqual:i,areMapsEqual:c,areObjectsEqual:l,areSetsEqual:f})}return o}(r),O=k(f);return function(r){var e=r.circular,t=r.comparator,a=r.createState,n=r.equals,u=r.strict;if(a)return function(r,o){var i=a(),c=i.cache,l=void 0===c?e?new WeakMap:void 0:c,f=i.meta;return t(r,o,{cache:l,equals:n,meta:f,strict:u})};if(e)return function(r,e){return t(r,e,{cache:new WeakMap,equals:n,meta:void 0,strict:u})};var o={cache:void 0,equals:n,meta:void 0,strict:u};return function(r,e){return t(r,e,o)}}({circular:a,comparator:O,createState:i,equals:o?o(O):(e=O,function(r,t,a,n,u,o,i){return e(r,t,i)}),strict:l})}r.circularDeepEqual=M,r.circularShallowEqual=_,r.createCustomEqual=B,r.deepEqual=T,r.sameValueZeroEqual=c,r.shallowEqual=I,r.strictCircularDeepEqual=P,r.strictCircularShallowEqual=z,r.strictDeepEqual=D,r.strictShallowEqual=R});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ComparatorConfig, CreateState, CustomEqualCreatorOptions, EqualityComparator, InternalEqualityComparator } from './internalTypes.js';
|
|
2
|
-
interface CreateIsEqualOptions<Meta> {
|
|
3
|
-
circular: boolean;
|
|
4
|
-
comparator: EqualityComparator<Meta>;
|
|
5
|
-
createState: CreateState<Meta> | undefined;
|
|
6
|
-
equals: InternalEqualityComparator<Meta>;
|
|
7
|
-
strict: boolean;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Create a comparator method based on the type-specific equality comparators passed.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createEqualityComparator<Meta>({ areArraysEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, unknownTagComparators, }: ComparatorConfig<Meta>): EqualityComparator<Meta>;
|
|
13
|
-
/**
|
|
14
|
-
* Create the configuration object used for building comparators.
|
|
15
|
-
*/
|
|
16
|
-
export declare function createEqualityComparatorConfig<Meta>({ circular, createCustomConfig, strict, }: CustomEqualCreatorOptions<Meta>): ComparatorConfig<Meta>;
|
|
17
|
-
/**
|
|
18
|
-
* Default equality comparator pass-through, used as the standard `isEqual` creator for
|
|
19
|
-
* use inside the built comparator.
|
|
20
|
-
*/
|
|
21
|
-
export declare function createInternalEqualityComparator<Meta>(compare: EqualityComparator<Meta>): InternalEqualityComparator<Meta>;
|
|
22
|
-
/**
|
|
23
|
-
* Create the `isEqual` function used by the consuming application.
|
|
24
|
-
*/
|
|
25
|
-
export declare function createIsEqual<Meta>({ circular, comparator, createState, equals, strict, }: CreateIsEqualOptions<Meta>): <A, B>(a: A, b: B) => boolean;
|
|
26
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { Dictionary, PrimitiveWrapper, State, TypedArray } from './internalTypes.js';
|
|
2
|
-
import { sameValueZeroEqual } from './utils.js';
|
|
3
|
-
/**
|
|
4
|
-
* Whether the arrays are equal in value.
|
|
5
|
-
*/
|
|
6
|
-
export declare function areArraysEqual(a: any[], b: any[], state: State<any>): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Whether the dates passed are equal in value.
|
|
9
|
-
*/
|
|
10
|
-
export declare function areDatesEqual(a: Date, b: Date): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Whether the errors passed are equal in value.
|
|
13
|
-
*/
|
|
14
|
-
export declare function areErrorsEqual(a: Error, b: Error): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Whether the functions passed are equal in value.
|
|
17
|
-
*/
|
|
18
|
-
export declare function areFunctionsEqual(a: (...args: any[]) => any, b: (...args: any[]) => any): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Whether the `Map`s are equal in value.
|
|
21
|
-
*/
|
|
22
|
-
export declare function areMapsEqual(a: Map<any, any>, b: Map<any, any>, state: State<any>): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Whether the numbers are equal in value.
|
|
25
|
-
*/
|
|
26
|
-
export declare const areNumbersEqual: typeof sameValueZeroEqual;
|
|
27
|
-
/**
|
|
28
|
-
* Whether the objects are equal in value.
|
|
29
|
-
*/
|
|
30
|
-
export declare function areObjectsEqual(a: Dictionary, b: Dictionary, state: State<any>): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Whether the objects are equal in value with strict property checking.
|
|
33
|
-
*/
|
|
34
|
-
export declare function areObjectsEqualStrict(a: Dictionary, b: Dictionary, state: State<any>): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Whether the primitive wrappers passed are equal in value.
|
|
37
|
-
*/
|
|
38
|
-
export declare function arePrimitiveWrappersEqual(a: PrimitiveWrapper, b: PrimitiveWrapper): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Whether the regexps passed are equal in value.
|
|
41
|
-
*/
|
|
42
|
-
export declare function areRegExpsEqual(a: RegExp, b: RegExp): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Whether the `Set`s are equal in value.
|
|
45
|
-
*/
|
|
46
|
-
export declare function areSetsEqual(a: Set<any>, b: Set<any>, state: State<any>): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Whether the TypedArray instances are equal in value.
|
|
49
|
-
*/
|
|
50
|
-
export declare function areTypedArraysEqual(a: TypedArray, b: TypedArray): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Whether the URL instances are equal in value.
|
|
53
|
-
*/
|
|
54
|
-
export declare function areUrlsEqual(a: URL, b: URL): boolean;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { CustomEqualCreatorOptions } from './internalTypes.js';
|
|
2
|
-
import { sameValueZeroEqual } from './utils.js';
|
|
3
|
-
export { sameValueZeroEqual };
|
|
4
|
-
export type { AnyEqualityComparator, Cache, CircularState, ComparatorConfig, CreateCustomComparatorConfig, CreateState, CustomEqualCreatorOptions, DefaultState, Dictionary, EqualityComparator, EqualityComparatorCreator, InternalEqualityComparator, PrimitiveWrapper, State, TypeEqualityComparator, TypedArray, } from './internalTypes.js';
|
|
5
|
-
/**
|
|
6
|
-
* Whether the items passed are deeply-equal in value.
|
|
7
|
-
*/
|
|
8
|
-
export declare const deepEqual: <A, B>(a: A, b: B) => boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Whether the items passed are deeply-equal in value based on strict comparison.
|
|
11
|
-
*/
|
|
12
|
-
export declare const strictDeepEqual: <A, B>(a: A, b: B) => boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Whether the items passed are deeply-equal in value, including circular references.
|
|
15
|
-
*/
|
|
16
|
-
export declare const circularDeepEqual: <A, B>(a: A, b: B) => boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Whether the items passed are deeply-equal in value, including circular references,
|
|
19
|
-
* based on strict comparison.
|
|
20
|
-
*/
|
|
21
|
-
export declare const strictCircularDeepEqual: <A, B>(a: A, b: B) => boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Whether the items passed are shallowly-equal in value.
|
|
24
|
-
*/
|
|
25
|
-
export declare const shallowEqual: <A, B>(a: A, b: B) => boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Whether the items passed are shallowly-equal in value based on strict comparison
|
|
28
|
-
*/
|
|
29
|
-
export declare const strictShallowEqual: <A, B>(a: A, b: B) => boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Whether the items passed are shallowly-equal in value, including circular references.
|
|
32
|
-
*/
|
|
33
|
-
export declare const circularShallowEqual: <A, B>(a: A, b: B) => boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Whether the items passed are shallowly-equal in value, including circular references,
|
|
36
|
-
* based on strict comparison.
|
|
37
|
-
*/
|
|
38
|
-
export declare const strictCircularShallowEqual: <A, B>(a: A, b: B) => boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Create a custom equality comparison method.
|
|
41
|
-
*
|
|
42
|
-
* This can be done to create very targeted comparisons in extreme hot-path scenarios
|
|
43
|
-
* where the standard methods are not performant enough, but can also be used to provide
|
|
44
|
-
* support for legacy environments that do not support expected features like
|
|
45
|
-
* `RegExp.prototype.flags` out of the box.
|
|
46
|
-
*/
|
|
47
|
-
export declare function createCustomEqual<Meta = undefined>(options?: CustomEqualCreatorOptions<Meta>): <A, B>(a: A, b: B) => boolean;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache used to store references to objects, used for circular
|
|
3
|
-
* reference checks.
|
|
4
|
-
*/
|
|
5
|
-
export interface Cache<Key extends object, Value> {
|
|
6
|
-
delete(key: Key): boolean;
|
|
7
|
-
get(key: Key): Value | undefined;
|
|
8
|
-
set(key: Key, value: any): any;
|
|
9
|
-
}
|
|
10
|
-
export interface State<Meta> {
|
|
11
|
-
/**
|
|
12
|
-
* Cache used to identify circular references
|
|
13
|
-
*/
|
|
14
|
-
readonly cache: Cache<any, any> | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Method used to determine equality of nested value.
|
|
17
|
-
*/
|
|
18
|
-
readonly equals: InternalEqualityComparator<Meta>;
|
|
19
|
-
/**
|
|
20
|
-
* Additional value that can be used for comparisons.
|
|
21
|
-
*/
|
|
22
|
-
meta: Meta;
|
|
23
|
-
/**
|
|
24
|
-
* Whether the equality comparison is strict, meaning it matches
|
|
25
|
-
* all properties (including symbols and non-enumerable properties)
|
|
26
|
-
* with equal shape of descriptors.
|
|
27
|
-
*/
|
|
28
|
-
readonly strict: boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface CircularState<Meta> extends State<Meta> {
|
|
31
|
-
readonly cache: Cache<any, any>;
|
|
32
|
-
}
|
|
33
|
-
export interface DefaultState<Meta> extends State<Meta> {
|
|
34
|
-
readonly cache: undefined;
|
|
35
|
-
}
|
|
36
|
-
export interface Dictionary<Value = any> {
|
|
37
|
-
[key: string | symbol]: Value;
|
|
38
|
-
$$typeof?: any;
|
|
39
|
-
}
|
|
40
|
-
export interface ComparatorConfig<Meta> {
|
|
41
|
-
/**
|
|
42
|
-
* Whether the arrays passed are equal in value. In strict mode, this includes
|
|
43
|
-
* additional properties added to the array.
|
|
44
|
-
*/
|
|
45
|
-
areArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
46
|
-
/**
|
|
47
|
-
* Whether the dates passed are equal in value.
|
|
48
|
-
*/
|
|
49
|
-
areDatesEqual: TypeEqualityComparator<any, Meta>;
|
|
50
|
-
/**
|
|
51
|
-
* Whether the errors passed are equal in value.
|
|
52
|
-
*/
|
|
53
|
-
areErrorsEqual: TypeEqualityComparator<any, Meta>;
|
|
54
|
-
/**
|
|
55
|
-
* Whether the functions passed are equal in value.
|
|
56
|
-
*/
|
|
57
|
-
areFunctionsEqual: TypeEqualityComparator<any, Meta>;
|
|
58
|
-
/**
|
|
59
|
-
* Whether the maps passed are equal in value. In strict mode, this includes
|
|
60
|
-
* additional properties added to the map.
|
|
61
|
-
*/
|
|
62
|
-
areMapsEqual: TypeEqualityComparator<any, Meta>;
|
|
63
|
-
/**
|
|
64
|
-
* Whether the numbers passed are equal in value.
|
|
65
|
-
*/
|
|
66
|
-
areNumbersEqual: TypeEqualityComparator<any, Meta>;
|
|
67
|
-
/**
|
|
68
|
-
* Whether the objects passed are equal in value. In strict mode, this includes
|
|
69
|
-
* non-enumerable properties added to the map, as well as symbol properties.
|
|
70
|
-
*/
|
|
71
|
-
areObjectsEqual: TypeEqualityComparator<any, Meta>;
|
|
72
|
-
/**
|
|
73
|
-
* Whether the primitive wrappers passed are equal in value.
|
|
74
|
-
*/
|
|
75
|
-
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
|
|
76
|
-
/**
|
|
77
|
-
* Whether the regexps passed are equal in value.
|
|
78
|
-
*/
|
|
79
|
-
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
|
|
80
|
-
/**
|
|
81
|
-
* Whether the sets passed are equal in value. In strict mode, this includes
|
|
82
|
-
* additional properties added to the set.
|
|
83
|
-
*/
|
|
84
|
-
areSetsEqual: TypeEqualityComparator<any, Meta>;
|
|
85
|
-
/**
|
|
86
|
-
* Whether the typed arrays passed are equal in value. In strict mode, this includes
|
|
87
|
-
* additional properties added to the typed array.
|
|
88
|
-
*/
|
|
89
|
-
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
|
|
90
|
-
/**
|
|
91
|
-
* Whether the URLs passed are equal in value.
|
|
92
|
-
*/
|
|
93
|
-
areUrlsEqual: TypeEqualityComparator<any, Meta>;
|
|
94
|
-
/**
|
|
95
|
-
* Whether two values with unknown `@@toStringTag` are equal in value. This comparator is
|
|
96
|
-
* called when no other comparator applies.
|
|
97
|
-
*
|
|
98
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag
|
|
99
|
-
*/
|
|
100
|
-
unknownTagComparators: Record<string, TypeEqualityComparator<any, Meta>> | undefined;
|
|
101
|
-
}
|
|
102
|
-
export type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
|
|
103
|
-
export type CreateState<Meta> = () => {
|
|
104
|
-
cache?: Cache<any, any> | undefined;
|
|
105
|
-
meta?: Meta;
|
|
106
|
-
};
|
|
107
|
-
export type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) => boolean;
|
|
108
|
-
export type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
|
|
109
|
-
export type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
|
|
110
|
-
export type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
|
|
111
|
-
export type PrimitiveWrapper = Boolean | Number | String;
|
|
112
|
-
/**
|
|
113
|
-
* Type which encompasses possible instances of TypedArray
|
|
114
|
-
* classes.
|
|
115
|
-
*
|
|
116
|
-
* **NOTE**: This does not include `BigInt64Array` and
|
|
117
|
-
* `BitUint64Array` because those are part of ES2020 and
|
|
118
|
-
* not supported by certain TS configurations. If using
|
|
119
|
-
* either in `areTypedArraysEqual`, you can cast the
|
|
120
|
-
* instance as `TypedArray` and it will work as expected,
|
|
121
|
-
* because runtime checks will still work for those classes.
|
|
122
|
-
*/
|
|
123
|
-
export type TypedArray = Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
|
|
124
|
-
export type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
|
|
125
|
-
export interface CustomEqualCreatorOptions<Meta> {
|
|
126
|
-
/**
|
|
127
|
-
* Whether circular references should be supported. It causes the
|
|
128
|
-
* comparison to be slower, but for objects that have circular references
|
|
129
|
-
* it is required to avoid stack overflows.
|
|
130
|
-
*/
|
|
131
|
-
circular?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Create a custom configuration of type-specific equality comparators.
|
|
134
|
-
* This receives the default configuration, which allows either replacement
|
|
135
|
-
* or supersetting of the default methods.
|
|
136
|
-
*/
|
|
137
|
-
createCustomConfig?: CreateCustomComparatorConfig<Meta>;
|
|
138
|
-
/**
|
|
139
|
-
* Create a custom internal comparator, which is used as an override to the
|
|
140
|
-
* default entry point for nested value equality comparisons. This is often
|
|
141
|
-
* used for doing custom logic for specific types (such as handling a specific
|
|
142
|
-
* class instance differently than other objects) or to incorporate `meta` in
|
|
143
|
-
* the comparison. See the recipes for examples.
|
|
144
|
-
*/
|
|
145
|
-
createInternalComparator?: (compare: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
|
|
146
|
-
/**
|
|
147
|
-
* Create a custom `state` object passed between the methods. This allows for
|
|
148
|
-
* custom `cache` and/or `meta` values to be used.
|
|
149
|
-
*/
|
|
150
|
-
createState?: CreateState<Meta>;
|
|
151
|
-
/**
|
|
152
|
-
* Whether the equality comparison is strict, meaning it matches
|
|
153
|
-
* all properties (including symbols and non-enumerable properties)
|
|
154
|
-
* with equal shape of descriptors.
|
|
155
|
-
*/
|
|
156
|
-
strict?: boolean;
|
|
157
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AnyEqualityComparator, Dictionary, State, TypeEqualityComparator } from './internalTypes.js';
|
|
2
|
-
/**
|
|
3
|
-
* Combine two comparators into a single comparators.
|
|
4
|
-
*/
|
|
5
|
-
export declare function combineComparators<Meta>(comparatorA: AnyEqualityComparator<Meta>, comparatorB: AnyEqualityComparator<Meta>): <A, B>(a: A, b: B, state: State<Meta>) => boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Wrap the provided `areItemsEqual` method to manage the circular state, allowing
|
|
8
|
-
* for circular references to be safely included in the comparison without creating
|
|
9
|
-
* stack overflows.
|
|
10
|
-
*/
|
|
11
|
-
export declare function createIsCircular<AreItemsEqual extends TypeEqualityComparator<any, any>>(areItemsEqual: AreItemsEqual): AreItemsEqual;
|
|
12
|
-
/**
|
|
13
|
-
* Get the `@@toStringTag` of the value, if it exists.
|
|
14
|
-
*/
|
|
15
|
-
export declare function getShortTag(value: any): string | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Get the properties to strictly examine, which include both own properties that are
|
|
18
|
-
* not enumerable and symbol properties.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getStrictProperties(object: Dictionary): Array<string | symbol>;
|
|
21
|
-
/**
|
|
22
|
-
* Whether the object contains the property passed as an own property.
|
|
23
|
-
*/
|
|
24
|
-
export declare const hasOwn: (o: object, v: PropertyKey) => boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Whether the values passed are strictly equal or both NaN.
|
|
27
|
-
*/
|
|
28
|
-
export declare function sameValueZeroEqual(a: any, b: any): boolean;
|