fast-equals 5.4.0 → 5.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,159 +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 array buffers passed are equal in value. In strict mode, this includes
43
- * additional properties added to the array.
44
- */
45
- areArrayBuffersEqual: TypeEqualityComparator<any, Meta>;
46
- /**
47
- * Whether the arrays passed are equal in value. In strict mode, this includes
48
- * additional properties added to the array.
49
- */
50
- areArraysEqual: TypeEqualityComparator<any, Meta>;
51
- /**
52
- * Whether the data views passed are equal in value.
53
- */
54
- areDataViewsEqual: TypeEqualityComparator<any, Meta>;
55
- /**
56
- * Whether the dates passed are equal in value.
57
- */
58
- areDatesEqual: TypeEqualityComparator<any, Meta>;
59
- /**
60
- * Whether the errors passed are equal in value.
61
- */
62
- areErrorsEqual: TypeEqualityComparator<any, Meta>;
63
- /**
64
- * Whether the functions passed are equal in value.
65
- */
66
- areFunctionsEqual: TypeEqualityComparator<any, Meta>;
67
- /**
68
- * Whether the maps passed are equal in value. In strict mode, this includes
69
- * additional properties added to the map.
70
- */
71
- areMapsEqual: TypeEqualityComparator<any, Meta>;
72
- /**
73
- * Whether the numbers passed are equal in value.
74
- */
75
- areNumbersEqual: TypeEqualityComparator<any, Meta>;
76
- /**
77
- * Whether the objects passed are equal in value. In strict mode, this includes
78
- * non-enumerable properties added to the map, as well as symbol properties.
79
- */
80
- areObjectsEqual: TypeEqualityComparator<any, Meta>;
81
- /**
82
- * Whether the primitive wrappers passed are equal in value.
83
- */
84
- arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
85
- /**
86
- * Whether the regexps passed are equal in value.
87
- */
88
- areRegExpsEqual: TypeEqualityComparator<any, Meta>;
89
- /**
90
- * Whether the sets passed are equal in value. In strict mode, this includes
91
- * additional properties added to the set.
92
- */
93
- areSetsEqual: TypeEqualityComparator<any, Meta>;
94
- /**
95
- * Whether the typed arrays passed are equal in value. In strict mode, this includes
96
- * additional properties added to the typed array.
97
- */
98
- areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
99
- /**
100
- * Whether the URLs passed are equal in value.
101
- */
102
- areUrlsEqual: TypeEqualityComparator<any, Meta>;
103
- /**
104
- * Whether two values with unknown `@@toStringTag` are equal in value. This comparator is
105
- * called when no other comparator applies.
106
- *
107
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag
108
- */
109
- unknownTagComparators: Record<string, TypeEqualityComparator<any, Meta>> | undefined;
110
- }
111
- export type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
112
- export type CreateState<Meta> = () => {
113
- cache?: Cache<any, any> | undefined;
114
- meta?: Meta;
115
- };
116
- export type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) => boolean;
117
- export type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
118
- export type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
119
- export type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;
120
- export type PrimitiveWrapper = Boolean | Number | String;
121
- /**
122
- * Type which encompasses possible instances of TypedArray
123
- * classes.
124
- */
125
- export type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
126
- export type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
127
- export interface CustomEqualCreatorOptions<Meta> {
128
- /**
129
- * Whether circular references should be supported. It causes the
130
- * comparison to be slower, but for objects that have circular references
131
- * it is required to avoid stack overflows.
132
- */
133
- circular?: boolean;
134
- /**
135
- * Create a custom configuration of type-specific equality comparators.
136
- * This receives the default configuration, which allows either replacement
137
- * or supersetting of the default methods.
138
- */
139
- createCustomConfig?: CreateCustomComparatorConfig<Meta>;
140
- /**
141
- * Create a custom internal comparator, which is used as an override to the
142
- * default entry point for nested value equality comparisons. This is often
143
- * used for doing custom logic for specific types (such as handling a specific
144
- * class instance differently than other objects) or to incorporate `meta` in
145
- * the comparison. See the recipes for examples.
146
- */
147
- createInternalComparator?: (compare: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
148
- /**
149
- * Create a custom `state` object passed between the methods. This allows for
150
- * custom `cache` and/or `meta` values to be used.
151
- */
152
- createState?: CreateState<Meta>;
153
- /**
154
- * Whether the equality comparison is strict, meaning it matches
155
- * all properties (including symbols and non-enumerable properties)
156
- * with equal shape of descriptors.
157
- */
158
- strict?: boolean;
159
- }
@@ -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;