File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 131
131
return 'array' ;
132
132
} else if ( Object . prototype . toString . call ( subject ) === '[object Date]' ) {
133
133
return 'date' ;
134
- } else if ( typeof subject . toString !== 'undefined ' && / ^ \/ .* \/ / . test ( subject . toString ( ) ) ) {
134
+ } else if ( typeof subject . toString === 'function ' && / ^ \/ .* \/ / . test ( subject . toString ( ) ) ) {
135
135
return 'regexp' ;
136
136
}
137
137
return 'object' ;
Original file line number Diff line number Diff line change @@ -532,4 +532,23 @@ describe('deep-diff', function() {
532
532
} ) ;
533
533
} ) ;
534
534
535
+ describe ( 'subject.toString is not a function' , function ( ) {
536
+ var lhs = {
537
+ left : 'yes' ,
538
+ right : 'no' ,
539
+ } ;
540
+ var rhs = {
541
+ left : {
542
+ toString : true ,
543
+ } ,
544
+ right : 'no' ,
545
+ } ;
546
+
547
+ it ( 'should not throw a TypeError' , function ( ) {
548
+ var diff = deep . diff ( lhs , rhs ) ;
549
+
550
+ expect ( diff . length ) . to . be ( 1 ) ;
551
+ } ) ;
552
+ } ) ;
553
+
535
554
} ) ;
You can’t perform that action at this time.
0 commit comments