Add function to remove circular references and use it in SpaceService

This commit is contained in:
faris Aljohari
2025-02-03 07:38:19 -06:00
parent 94bec00f7f
commit 9dcb68da2d
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,12 @@
export function removeCircularReferences() {
const seen = new WeakSet();
return (key: string, value: any) => {
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
return undefined; // Skip circular reference
}
seen.add(value);
}
return value;
};
}