cal.pub0.org/packages/lib/safeStringify.ts

9 lines
169 B
TypeScript

export function safeStringify(obj: unknown) {
try {
// Avoid crashing on circular references
return JSON.stringify(obj);
} catch (e) {
return obj;
}
}