WIP
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
export function safeStringify(obj) {
|
||||
const seen = new WeakSet();
|
||||
|
||||
return JSON.stringify(obj, (key, value) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (seen.has(value)) {
|
||||
return `[Circular ${key}]`; // Label circular reference with the key
|
||||
}
|
||||
seen.add(value);
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user