This commit is contained in:
2024-11-09 19:15:29 -05:00
parent 6d6e63ea0d
commit 23e234eac0
13 changed files with 460 additions and 9 deletions
+13
View File
@@ -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;
});
}