Added sanitizedJSON
Some checks failed
Build / Build NPM Project (push) Failing after 0s
Build / Tag Version (push) Has been skipped
Build / Publish (push) Has been skipped

This commit is contained in:
2024-04-14 07:53:58 -04:00
parent 65f8414a5c
commit 7324e89ad8
3 changed files with 14 additions and 3 deletions

View File

@ -153,3 +153,14 @@ export function mixin(target: any, constructors: any[]) {
});
});
}
export function sanitizedJSON(obj: any, space?: number) {
let cache: any[] = [];
return JSON.parse(JSON.stringify(obj, (key, value) => {
if (typeof value === 'object' && value !== null) {
if (cache.includes(value)) return;
cache.push(value);
}
return value;
}, space));
}