We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 278e5d7 commit 04e8606Copy full SHA for 04e8606
lib/utils/helpers.ts
@@ -118,12 +118,17 @@ export const isSafari = Object.prototype.toString.call(window.HTMLElement).index
118
|| (function (p) { return p.toString() === '[object SafariRemoteNotification]'; })(!window['safari']
119
|| safari.pushNotification);
120
121
+// works only for plain objects (JSON)
122
export function snapshot(obj) {
123
if(obj == undefined || typeof(obj) !== 'object') {
124
return obj;
125
}
126
- var temp = new obj.constructor();
127
+ if(obj instanceof Date) {
128
+ return new Date(obj.getTime());
129
+ }
130
+
131
+ var temp = Array.isArray(obj) ? [] : {};
132
133
for(var key in obj) {
134
if (obj.hasOwnProperty(key)) {
0 commit comments