File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ function isNonPrimitive(value: any): value is object {
2222/**
2323Recursively copy a value.
2424
25- @param source - should be a JavaScript primitive, Array, or (plain old) Object.
25+ @param source - should be a JavaScript primitive, Array, Date, or (plain old) Object.
2626@returns copy of source where every Array and Object have been recursively
2727 reconstructed from their constituent elements
2828*/
@@ -42,6 +42,11 @@ export function clone<T extends any>(source: T): T {
4242 }
4343 return arrayTarget
4444 }
45+ // Date
46+ if ( source . constructor == Date ) {
47+ const dateTarget : any = new Date ( + source )
48+ return dateTarget
49+ }
4550 // Object
4651 const objectTarget : any = { }
4752 // declaring the variable (with const) inside the loop is faster
You can’t perform that action at this time.
0 commit comments