1
1
import { isFn , isArr } from './types'
2
+ import { instOf } from './instanceof'
2
3
const isArray = isArr
3
4
const keyList = Object . keys
4
5
const hasProp = Object . prototype . hasOwnProperty
@@ -44,8 +45,8 @@ function equal(a: any, b: any, filter?: Filter) {
44
45
const immutableB = b && b . toJS
45
46
if ( immutableA !== immutableB ) return false
46
47
if ( immutableA ) return a . is ? a . is ( b ) : a === b
47
- const dateA = a instanceof Date
48
- const dateB = b instanceof Date
48
+ const dateA = instOf ( a , ' Date' )
49
+ const dateB = instOf ( b , ' Date' )
49
50
if ( dateA !== dateB ) {
50
51
return false
51
52
}
@@ -56,21 +57,18 @@ function equal(a: any, b: any, filter?: Filter) {
56
57
const schemaB = b && b . toJSON
57
58
if ( schemaA !== schemaB ) return false
58
59
if ( schemaA && schemaB ) return equal ( a . toJSON ( ) , b . toJSON ( ) , filter )
59
- const regexpA = a instanceof RegExp
60
- const regexpB = b instanceof RegExp
60
+ const regexpA = instOf ( a , ' RegExp' )
61
+ const regexpB = instOf ( b , ' RegExp' )
61
62
if ( regexpA !== regexpB ) {
62
63
return false
63
64
}
64
65
if ( regexpA && regexpB ) {
65
66
return a . toString ( ) === b . toString ( )
66
67
}
67
- // fix: Not in the browser
68
- if ( typeof URL !== void ( 0 ) ) {
69
- const urlA = a instanceof URL
70
- const urlB = b instanceof URL
71
- if ( urlA && urlB ) {
72
- return a . href === b . href
73
- }
68
+ const urlA = instOf ( a , 'URL' )
69
+ const urlB = instOf ( b , 'URL' )
70
+ if ( urlA && urlB ) {
71
+ return a . href === b . href
74
72
}
75
73
76
74
const keys = keyList ( a )
0 commit comments