UNPKG

persistent-typescript

Version:

An easy way to have persistent data on the browser and on nodejs

32 lines (31 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Map_1 = require("../utils/Map"); var Utils_1 = require("../utils/Utils"); var JsonPlugin = /** @class */ (function () { function JsonPlugin(isMinified) { this.minified = isMinified; } JsonPlugin.prototype.init = function () { return new Map_1.Map(); }; JsonPlugin.prototype.serialize = function (object) { if (Utils_1.Utils.isBrowser()) return object.toJson(true); return object.toJson(this.minified); }; JsonPlugin.prototype.deserialize = function (serializedObject) { return Map_1.Map.fromJson(serializedObject); }; JsonPlugin.prototype.get = function (object, className) { if (object == null) return null; return object.getValue(className); }; JsonPlugin.prototype.put = function (object, className, classInstance) { object.put(className, classInstance); }; return JsonPlugin; }()); exports.JsonPlugin = JsonPlugin; ;