UNPKG

1.69 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _Storage = require("./Storage");
8
9var _Storage2 = _interopRequireDefault(_Storage);
10
11function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13/**
14 * Implementation of the {@codelink Storage} interface that relies on the
15 * native {@code Map} for storage.
16 */
17class MapStorage extends _Storage2.default {
18 static get $dependencies() {
19 return [];
20 }
21 /**
22 * Initializes the map storage.
23 */
24
25
26 constructor() {
27 super();
28 /**
29 * The internal storage of entries.
30 *
31 * @protected
32 * @type {Map<string, *>}
33 */
34
35 this._storage = new Map();
36 }
37 /**
38 * @inheritdoc
39 */
40
41
42 init() {
43 return this;
44 }
45 /**
46 * @inheritdoc
47 */
48
49
50 has(key) {
51 return this._storage.has(key);
52 }
53 /**
54 * @inheritdoc
55 */
56
57
58 get(key) {
59 return this._storage.get(key);
60 }
61 /**
62 * @inheritdoc
63 */
64
65
66 set(key, value) {
67 this._storage.set(key, value);
68
69 return this;
70 }
71 /**
72 * @inheritdoc
73 */
74
75
76 delete(key) {
77 this._storage.delete(key);
78
79 return this;
80 }
81 /**
82 * @inheritdoc
83 */
84
85
86 clear() {
87 this._storage.clear();
88
89 return this;
90 }
91 /**
92 * @inheritdoc
93 */
94
95
96 keys() {
97 return this._storage.keys();
98 }
99 /**
100 * @override
101 */
102
103
104 size() {
105 return this._storage.size;
106 }
107
108}
109
110exports.default = MapStorage;
111
112typeof $IMA !== 'undefined' && $IMA !== null && $IMA.Loader && $IMA.Loader.register('ima/storage/MapStorage', [], function (_export, _context) {
113 'use strict';
114 return {
115 setters: [],
116 execute: function () {
117 _export('default', exports.default);
118 }
119 };
120});