@@ -22,8 +22,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
23
23
*/
24
24
25
- /* eslint-disable */
26
-
27
25
import type { Tester } from './types' ;
28
26
29
27
export type EqualsFunction = (
@@ -44,8 +42,8 @@ function isAsymmetric(obj: any) {
44
42
}
45
43
46
44
function asymmetricMatch ( a : any , b : any ) {
47
- var asymmetricA = isAsymmetric ( a ) ,
48
- asymmetricB = isAsymmetric ( b ) ;
45
+ const asymmetricA = isAsymmetric ( a ) ;
46
+ const asymmetricB = isAsymmetric ( b ) ;
49
47
50
48
if ( asymmetricA && asymmetricB ) {
51
49
return undefined ;
@@ -70,15 +68,15 @@ function eq(
70
68
customTesters : Array < Tester > ,
71
69
strictCheck : boolean | undefined ,
72
70
) : boolean {
73
- var result = true ;
71
+ let result = true ;
74
72
75
- var asymmetricResult = asymmetricMatch ( a , b ) ;
73
+ const asymmetricResult = asymmetricMatch ( a , b ) ;
76
74
if ( asymmetricResult !== undefined ) {
77
75
return asymmetricResult ;
78
76
}
79
77
80
- for ( var i = 0 ; i < customTesters . length ; i ++ ) {
81
- var customTesterResult = customTesters [ i ] ( a , b ) ;
78
+ for ( let i = 0 ; i < customTesters . length ; i ++ ) {
79
+ const customTesterResult = customTesters [ i ] ( a , b ) ;
82
80
if ( customTesterResult !== undefined ) {
83
81
return customTesterResult ;
84
82
}
@@ -95,7 +93,7 @@ function eq(
95
93
if ( a === null || b === null ) {
96
94
return a === b ;
97
95
}
98
- var className = Object . prototype . toString . call ( a ) ;
96
+ const className = Object . prototype . toString . call ( a ) ;
99
97
if ( className != Object . prototype . toString . call ( b ) ) {
100
98
return false ;
101
99
}
@@ -132,7 +130,7 @@ function eq(
132
130
}
133
131
134
132
// Used to detect circular references.
135
- var length = aStack . length ;
133
+ let length = aStack . length ;
136
134
while ( length -- ) {
137
135
// Linear search. Performance is inversely proportional to the number of
138
136
// unique nested structures.
@@ -154,19 +152,19 @@ function eq(
154
152
}
155
153
156
154
// Deep compare objects.
157
- var aKeys = keys ( a , hasKey ) ,
158
- key ;
155
+ const aKeys = keys ( a , hasKey ) ;
156
+ let key ;
159
157
160
- var bKeys = keys ( b , hasKey ) ;
158
+ const bKeys = keys ( b , hasKey ) ;
161
159
// Add keys corresponding to asymmetric matchers if they miss in non strict check mode
162
160
if ( ! strictCheck ) {
163
- for ( var index = 0 ; index !== bKeys . length ; ++ index ) {
161
+ for ( let index = 0 ; index !== bKeys . length ; ++ index ) {
164
162
key = bKeys [ index ] ;
165
163
if ( ( isAsymmetric ( b [ key ] ) || b [ key ] === undefined ) && ! hasKey ( a , key ) ) {
166
164
aKeys . push ( key ) ;
167
165
}
168
166
}
169
- for ( var index = 0 ; index !== aKeys . length ; ++ index ) {
167
+ for ( let index = 0 ; index !== aKeys . length ; ++ index ) {
170
168
key = aKeys [ index ] ;
171
169
if ( ( isAsymmetric ( a [ key ] ) || a [ key ] === undefined ) && ! hasKey ( b , key ) ) {
172
170
bKeys . push ( key ) ;
@@ -175,7 +173,7 @@ function eq(
175
173
}
176
174
177
175
// Ensure that both objects contain the same number of properties before comparing deep equality.
178
- var size = aKeys . length ;
176
+ let size = aKeys . length ;
179
177
if ( bKeys . length !== size ) {
180
178
return false ;
181
179
}
@@ -205,8 +203,8 @@ function eq(
205
203
}
206
204
207
205
function keys ( obj : object , hasKey : ( obj : object , key : string ) => boolean ) {
208
- var keys = [ ] ;
209
- for ( var key in obj ) {
206
+ const keys = [ ] ;
207
+ for ( const key in obj ) {
210
208
if ( hasKey ( obj , key ) ) {
211
209
keys . push ( key ) ;
212
210
}
@@ -225,7 +223,7 @@ function hasKey(obj: any, key: string) {
225
223
}
226
224
227
225
export function isA < T > ( typeName : string , value : unknown ) : value is T {
228
- return Object . prototype . toString . apply ( value ) === ' [object ' + typeName + ']' ;
226
+ return Object . prototype . toString . apply ( value ) === ` [object ${ typeName } ]` ;
229
227
}
230
228
231
229
function isDomNode ( obj : any ) : boolean {
@@ -237,50 +235,3 @@ function isDomNode(obj: any): boolean {
237
235
typeof obj . isEqualNode === 'function'
238
236
) ;
239
237
}
240
-
241
- // SENTINEL constants are from https://github.com/immutable-js/immutable-js/tree/main/src/predicates
242
- const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@' ;
243
- const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@' ;
244
- const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@' ;
245
- const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@' ;
246
- const IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@' ;
247
-
248
- export function isImmutableUnorderedKeyed ( maybeKeyed : any ) {
249
- return ! ! (
250
- maybeKeyed &&
251
- maybeKeyed [ IS_KEYED_SENTINEL ] &&
252
- ! maybeKeyed [ IS_ORDERED_SENTINEL ]
253
- ) ;
254
- }
255
-
256
- export function isImmutableUnorderedSet ( maybeSet : any ) {
257
- return ! ! (
258
- maybeSet &&
259
- maybeSet [ IS_SET_SENTINEL ] &&
260
- ! maybeSet [ IS_ORDERED_SENTINEL ]
261
- ) ;
262
- }
263
-
264
- export function isImmutableList ( maybeList : any ) {
265
- return ! ! ( maybeList && maybeList [ IS_LIST_SENTINEL ] ) ;
266
- }
267
-
268
- export function isImmutableOrderedKeyed ( maybeKeyed : any ) {
269
- return ! ! (
270
- maybeKeyed &&
271
- maybeKeyed [ IS_KEYED_SENTINEL ] &&
272
- maybeKeyed [ IS_ORDERED_SENTINEL ]
273
- ) ;
274
- }
275
-
276
- export function isImmutableOrderedSet ( maybeSet : any ) {
277
- return ! ! (
278
- maybeSet &&
279
- maybeSet [ IS_SET_SENTINEL ] &&
280
- maybeSet [ IS_ORDERED_SENTINEL ]
281
- ) ;
282
- }
283
-
284
- export function isImmutableRecord ( maybeSet : any ) {
285
- return ! ! ( maybeSet && maybeSet [ IS_RECORD_SYMBOL ] ) ;
286
- }
0 commit comments