topkat-utils 1.0.46 → 1.0.47
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.
- package/CHANGELOG.md +3 -0
- package/package.json +1 -1
- package/utils.ts +4 -4
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/utils.ts
CHANGED
|
@@ -492,17 +492,17 @@ function cloneObject(o) {
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
/** Deep clone. WILL REMOVE circular references */
|
|
495
|
-
function deepClone(obj, cache = []) {
|
|
495
|
+
function deepClone<T>(obj: T, cache = []): T {
|
|
496
496
|
|
|
497
497
|
let copy;
|
|
498
498
|
// usefull to not modify 1st level objet by lower levels
|
|
499
499
|
// this is required for the same object to be referenced not in a redundant way
|
|
500
500
|
const newCache = [...cache];
|
|
501
|
-
if (obj instanceof Date) return new Date(obj)
|
|
501
|
+
if (obj instanceof Date) return new Date(obj) as any
|
|
502
502
|
|
|
503
503
|
// Handle Array
|
|
504
504
|
if (Array.isArray(obj)) {
|
|
505
|
-
if (newCache.includes(obj)) return []
|
|
505
|
+
if (newCache.includes(obj)) return [] as any
|
|
506
506
|
newCache.push(obj);
|
|
507
507
|
copy = [];
|
|
508
508
|
for (var i = 0, len = obj.length; i < len; i++) {
|
|
@@ -512,7 +512,7 @@ function deepClone(obj, cache = []) {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
if (typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === Object.prototype) {
|
|
515
|
-
if (newCache.includes(obj)) return {}
|
|
515
|
+
if (newCache.includes(obj)) return {} as any
|
|
516
516
|
newCache.push(obj);
|
|
517
517
|
copy = {};
|
|
518
518
|
for (var key in obj) {
|