File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -227,6 +227,35 @@ export function sleep(ms: number) {
227
227
} ) ;
228
228
}
229
229
230
+ /**
231
+ * Test equality between two value whatever their type, array included
232
+ */
233
+ export function equal ( a : any , b : any ) {
234
+ if ( Object ( a ) !== a ) {
235
+ if ( Object ( b ) === b ) {
236
+ return false ;
237
+ }
238
+ // both primitive (null and undefined included)
239
+ return a === b ;
240
+ }
241
+ // complexe object
242
+ if ( a [ Symbol . iterator ] ) {
243
+ if ( ! b [ Symbol . iterator ] ) {
244
+ return false ;
245
+ }
246
+ if ( a . length !== b . length ) {
247
+ return false ;
248
+ }
249
+ for ( let i = 0 ; i !== a . length ; ++ i ) {
250
+ if ( a [ i ] !== b [ i ] ) {
251
+ return false ;
252
+ }
253
+ }
254
+ return true ;
255
+ }
256
+ return a === b ;
257
+ }
258
+
230
259
/**
231
260
* fetch help method with few usefull fix:
232
261
* - throw an string exception if response code is not 200 with the text of the response or uses statusText
You can’t perform that action at this time.
0 commit comments