@antscorp/antsomi-ui 1.3.5-beta.908 → 1.3.5-beta.909
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.
|
@@ -67,6 +67,7 @@ export declare const generateTagContent: (params: {
|
|
|
67
67
|
* // returns 'Hello "world" with spaces'
|
|
68
68
|
*/
|
|
69
69
|
export declare const unescapeString: (str: string) => string;
|
|
70
|
+
export declare function deepUnescape<T = any>(obj: T): T | string;
|
|
70
71
|
/**
|
|
71
72
|
* Checks if the string is a valid tag type.
|
|
72
73
|
* @param str
|
|
@@ -447,6 +447,21 @@ export const unescapeString = (str) => str.replace(/"| |nbsp;|'/g
|
|
|
447
447
|
return match;
|
|
448
448
|
}
|
|
449
449
|
});
|
|
450
|
+
export function deepUnescape(obj) {
|
|
451
|
+
// Base case: Return primitives as is
|
|
452
|
+
if (obj === null || typeof obj !== 'object') {
|
|
453
|
+
return typeof obj === 'string' ? unescapeString(obj) : obj;
|
|
454
|
+
}
|
|
455
|
+
// Handle arrays: Map and recurse
|
|
456
|
+
if (Array.isArray(obj)) {
|
|
457
|
+
return obj.map(deepUnescape);
|
|
458
|
+
}
|
|
459
|
+
// Handle objects: Recurse into key-value pairs
|
|
460
|
+
return Object.entries(obj).reduce((result, [key, value]) => {
|
|
461
|
+
result[key] = deepUnescape(value);
|
|
462
|
+
return result;
|
|
463
|
+
}, {});
|
|
464
|
+
}
|
|
450
465
|
/**
|
|
451
466
|
* Checks if the string is a valid tag type.
|
|
452
467
|
* @param str
|