@lorefnon/tslog
Version:
Extensible TypeScript Logger for Node.js and Browser.
20 lines (19 loc) • 592 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.jsonStringifyRecursive = void 0;
function jsonStringifyRecursive(obj) {
const cache = new Set();
return JSON.stringify(obj, (key, value) => {
if (typeof value === "object" && value !== null) {
if (cache.has(value)) {
return "[Circular]";
}
cache.add(value);
}
if (typeof value === "bigint") {
return `${value}`;
}
return value;
});
}
exports.jsonStringifyRecursive = jsonStringifyRecursive;