@rickyli79/rich-json
Version:
Serialize and Deserialize javascript objects
26 lines (25 loc) • 810 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MapSerializer = void 0;
const lib_1 = require("../lib");
class MapSerializer {
static instance;
static getInstance() {
if (this.instance === undefined) {
this.instance = (0, lib_1.createCustomerSerializer)({
class: Map,
toContent(value) {
return Array.from(value.entries());
},
fromContent(content) {
const map = new Map();
content.forEach(([key, value]) => map.set(key, value));
return map;
},
serializContent: true,
});
}
return this.instance;
}
}
exports.MapSerializer = MapSerializer;