@@ -668,8 +668,8 @@ function isBlob(obj) {
668
668
}
669
669
670
670
671
- function isBoolean ( value ) {
672
- return typeof value === 'boolean' ;
671
+ function isBoolean ( obj ) {
672
+ return typeof obj === 'boolean' ;
673
673
}
674
674
675
675
@@ -886,16 +886,7 @@ function copy(source, destination) {
886
886
if ( isArray ( source ) ) {
887
887
destination = [ ] ;
888
888
needsRecurse = true ;
889
- } else if ( isTypedArray ( source ) ) {
890
- destination = new source . constructor ( source ) ;
891
- } else if ( isDate ( source ) ) {
892
- destination = new Date ( source . getTime ( ) ) ;
893
- } else if ( isRegExp ( source ) ) {
894
- destination = new RegExp ( source . source , source . toString ( ) . match ( / [ ^ \/ ] * $ / ) [ 0 ] ) ;
895
- destination . lastIndex = source . lastIndex ;
896
- } else if ( isFunction ( source . cloneNode ) ) {
897
- destination = source . cloneNode ( true ) ;
898
- } else {
889
+ } else if ( ! ( destination = copyType ( source ) ) ) {
899
890
destination = Object . create ( getPrototypeOf ( source ) ) ;
900
891
needsRecurse = true ;
901
892
}
@@ -907,6 +898,36 @@ function copy(source, destination) {
907
898
? copyRecurse ( source , destination )
908
899
: destination ;
909
900
}
901
+
902
+ function copyType ( source ) {
903
+ switch ( toString . call ( source ) ) {
904
+ case '[object Int8Array]' :
905
+ case '[object Int16Array]' :
906
+ case '[object Int32Array]' :
907
+ case '[object Float32Array]' :
908
+ case '[object Float64Array]' :
909
+ case '[object Uint8Array]' :
910
+ case '[object Uint8ClampedArray]' :
911
+ case '[object Uint16Array]' :
912
+ case '[object Uint32Array]' :
913
+ case '[object Boolean]' :
914
+ case '[object Number]' :
915
+ case '[object String]' :
916
+ return new source . constructor ( source ) ;
917
+
918
+ case '[object Date]' :
919
+ return new Date ( source . getTime ( ) ) ;
920
+
921
+ case '[object RegExp]' :
922
+ var re = new RegExp ( source . source , source . toString ( ) . match ( / [ ^ \/ ] * $ / ) [ 0 ] ) ;
923
+ re . lastIndex = source . lastIndex ;
924
+ return re ;
925
+ }
926
+
927
+ if ( isFunction ( source . cloneNode ) ) {
928
+ return source . cloneNode ( true ) ;
929
+ }
930
+ }
910
931
}
911
932
912
933
/**
0 commit comments