@ethlete/core 0.2.0-next.18 → 0.2.0-next.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -568,57 +568,57 @@ const set = (obj, key, val) => {
|
|
|
568
568
|
else
|
|
569
569
|
obj[key] = val.value;
|
|
570
570
|
};
|
|
571
|
-
const clone = (
|
|
572
|
-
if (typeof
|
|
573
|
-
return
|
|
574
|
-
var
|
|
575
|
-
var i = 0, k, list, tmp, str = Object.prototype.toString.call(
|
|
571
|
+
const clone = (original) => {
|
|
572
|
+
if (typeof original !== 'object')
|
|
573
|
+
return original;
|
|
574
|
+
var _og = original;
|
|
575
|
+
var i = 0, k, list, tmp, str = Object.prototype.toString.call(_og);
|
|
576
576
|
if (str === '[object Object]') {
|
|
577
|
-
tmp = Object.create(
|
|
577
|
+
tmp = Object.create(_og.__proto__ || null);
|
|
578
578
|
}
|
|
579
579
|
else if (str === '[object Array]') {
|
|
580
|
-
tmp = Array(
|
|
580
|
+
tmp = Array(_og.length);
|
|
581
581
|
}
|
|
582
582
|
else if (str === '[object Set]') {
|
|
583
583
|
tmp = new Set();
|
|
584
|
-
|
|
584
|
+
_og.forEach(function (val) {
|
|
585
585
|
tmp.add(clone(val));
|
|
586
586
|
});
|
|
587
587
|
}
|
|
588
588
|
else if (str === '[object Map]') {
|
|
589
589
|
tmp = new Map();
|
|
590
|
-
|
|
590
|
+
_og.forEach(function (val, key) {
|
|
591
591
|
tmp.set(clone(key), clone(val));
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
594
|
else if (str === '[object Date]') {
|
|
595
|
-
tmp = new Date(+
|
|
595
|
+
tmp = new Date(+_og);
|
|
596
596
|
}
|
|
597
597
|
else if (str === '[object RegExp]') {
|
|
598
|
-
tmp = new RegExp(
|
|
598
|
+
tmp = new RegExp(_og.source, _og.flags);
|
|
599
599
|
}
|
|
600
600
|
else if (str === '[object DataView]') {
|
|
601
|
-
tmp = new
|
|
601
|
+
tmp = new _og.constructor(clone(_og.buffer));
|
|
602
602
|
}
|
|
603
603
|
else if (str === '[object ArrayBuffer]') {
|
|
604
|
-
tmp =
|
|
604
|
+
tmp = _og.slice(0);
|
|
605
605
|
}
|
|
606
606
|
else if (str.slice(-6) === 'Array]') {
|
|
607
607
|
// ArrayBuffer.isView(x)
|
|
608
608
|
// ~> `new` bcuz `Buffer.slice` => ref
|
|
609
|
-
tmp = new
|
|
609
|
+
tmp = new _og.constructor(_og);
|
|
610
610
|
}
|
|
611
611
|
if (tmp) {
|
|
612
|
-
for (list = Object.getOwnPropertySymbols(
|
|
613
|
-
set(tmp, list[i], Object.getOwnPropertyDescriptor(
|
|
612
|
+
for (list = Object.getOwnPropertySymbols(_og); i < list.length; i++) {
|
|
613
|
+
set(tmp, list[i], Object.getOwnPropertyDescriptor(_og, list[i]));
|
|
614
614
|
}
|
|
615
|
-
for (i = 0, list = Object.getOwnPropertyNames(
|
|
616
|
-
if (Object.hasOwnProperty.call(tmp, (k = list[i])) && tmp[k] ===
|
|
615
|
+
for (i = 0, list = Object.getOwnPropertyNames(_og); i < list.length; i++) {
|
|
616
|
+
if (Object.hasOwnProperty.call(tmp, (k = list[i])) && tmp[k] === _og[k])
|
|
617
617
|
continue;
|
|
618
|
-
set(tmp, k, Object.getOwnPropertyDescriptor(
|
|
618
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(_og, k));
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
-
return tmp ||
|
|
621
|
+
return tmp || _og;
|
|
622
622
|
};
|
|
623
623
|
|
|
624
624
|
const hasCookie = (name) => {
|