Added JSONAttemptParse & fixed uploadProgress response
All checks were successful
Build / Build NPM Project (push) Successful in 28s
Build / Tag Version (push) Successful in 7s

This commit is contained in:
2024-08-17 14:21:05 -04:00
parent 2d63db0ebb
commit 6d13df39f5
3 changed files with 12 additions and 5 deletions

View File

@ -186,7 +186,12 @@ export function mixin(target: any, constructors: any[]) {
});
}
export function sanitizedJSON(obj: any, space?: number) {
export function JSONAttemptParse<T>(json: string): T | string {
try { return JSON.parse(json); }
catch { return json; }
}
export function JSONSanitized(obj: any, space?: number) {
let cache: any[] = [];
return JSON.parse(JSON.stringify(obj, (key, value) => {
if (typeof value === 'object' && value !== null) {