UNPKG

1.34 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var MapCache = (function () {
4 function MapCache(data) {
5 if (data === void 0) { data = {}; }
6 this.cache = new Map(Object.entries(data));
7 }
8 MapCache.prototype.get = function (dataId) {
9 return this.cache.get("" + dataId);
10 };
11 MapCache.prototype.set = function (dataId, value) {
12 this.cache.set("" + dataId, value);
13 };
14 MapCache.prototype.delete = function (dataId) {
15 this.cache.delete("" + dataId);
16 };
17 MapCache.prototype.clear = function () {
18 return this.cache.clear();
19 };
20 MapCache.prototype.toObject = function () {
21 var obj = {};
22 this.cache.forEach(function (dataId, key) {
23 obj[key] = dataId;
24 });
25 return obj;
26 };
27 MapCache.prototype.replace = function (newData) {
28 var _this = this;
29 this.cache.clear();
30 Object.entries(newData).forEach(function (_a) {
31 var dataId = _a[0], value = _a[1];
32 return _this.cache.set(dataId, value);
33 });
34 };
35 return MapCache;
36}());
37exports.MapCache = MapCache;
38function mapNormalizedCacheFactory(seed) {
39 return new MapCache(seed);
40}
41exports.mapNormalizedCacheFactory = mapNormalizedCacheFactory;
42//# sourceMappingURL=mapCache.js.map
\No newline at end of file