UNPKG

@allgemein/eventbus

Version:
22 lines 679 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Serializer = void 0; const bson_1 = require("bson"); const lodash_1 = require("lodash"); class Serializer { static serialize(data) { // return JSON.stringify(data); const buffer = (0, bson_1.serialize)(data); // @ts-ignore return buffer.toString('base64'); } static deserialize(data) { if (!(0, lodash_1.isBuffer)(data)) { data = Buffer.from(data, 'base64'); } // return JSON.parse(data); return (0, bson_1.deserialize)(data); } } exports.Serializer = Serializer; //# sourceMappingURL=Serializer.js.map