1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var 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 | }());
|
37 | exports.MapCache = MapCache;
|
38 | function mapNormalizedCacheFactory(seed) {
|
39 | return new MapCache(seed);
|
40 | }
|
41 | exports.mapNormalizedCacheFactory = mapNormalizedCacheFactory;
|
42 |
|
\ | No newline at end of file |