UNPKG

@clynn-fe/akfe-editor-jsonf

Version:

JSON methods support function parse and stringify

24 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldBlockSelfToJSON = exports.blockSelfToJSON = void 0; const type_detectors_1 = require("./type_detectors"); const clone = (target) => { if ((0, type_detectors_1.isDate)(target)) return new Date(target.getTime()); if ((0, type_detectors_1.isMap)(target)) return new Map([...target.entries()]); if ((0, type_detectors_1.isSet)(target)) return new Set([...target.values()]); return {}; }; // eslint-disable-next-line @typescript-eslint/ban-types const blockSelfToJSON = (target) => Object.assign(clone(target), { toJSON: undefined }); exports.blockSelfToJSON = blockSelfToJSON; // eslint-disable-next-line @typescript-eslint/ban-types const shouldBlockSelfToJSON = (target) => { return (0, type_detectors_1.isDate)(target) || (0, type_detectors_1.isMap)(target) || (0, type_detectors_1.isSet)(target); }; exports.shouldBlockSelfToJSON = shouldBlockSelfToJSON; //# sourceMappingURL=utils.js.map