ox
Version:
23 lines • 843 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = parse;
exports.stringify = stringify;
const bigIntSuffix = '#__bigint';
function parse(string, reviver) {
return JSON.parse(string, (key, value_) => {
const value = value_;
if (typeof value === 'string' && value.endsWith(bigIntSuffix))
return BigInt(value.slice(0, -bigIntSuffix.length));
return typeof reviver === 'function' ? reviver(key, value) : value;
});
}
function stringify(value, replacer, space) {
return JSON.stringify(value, (key, value) => {
if (typeof replacer === 'function')
return replacer(key, value);
if (typeof value === 'bigint')
return value.toString() + bigIntSuffix;
return value;
}, space);
}
//# sourceMappingURL=Json.js.map
;