"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toJson = toJson;
exports.fromJson = fromJson;
exports.safeJsonStringify = safeJsonStringify;
function toJson(data) {
    return JSON.stringify(data);
}
function fromJson(serialized) {
    return JSON.parse(serialized);
}
function safeJsonStringify(data) {
    const ancestors = [];
    return JSON.stringify(data, function (_key, value) {
        if (typeof value !== 'object' || value === null)
            return value;
        while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
            ancestors.pop();
        if (ancestors.includes(value))
            return '[Circular]';
        ancestors.push(value);
        return value;
    });
}
//# sourceMappingURL=serialization.js.map