mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
Add function to remove circular references and use it in SpaceService
This commit is contained in:
12
libs/common/src/helper/removeCircularReferences.ts
Normal file
12
libs/common/src/helper/removeCircularReferences.ts
Normal 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;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user