UNPKG

1.68 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 /**
23 * Initializes the map storage.
24 */
25 constructor() {
26 super();
27
28 /**
29 * The internal storage of entries.
30 *
31 * @protected
32 * @type {Map<string, *>}
33 */
34 this._storage = new Map();
35 }
36
37 /**
38 * @inheritdoc
39 */
40 init() {
41 return this;
42 }
43
44 /**
45 * @inheritdoc
46 */
47 has(key) {
48 return this._storage.has(key);
49 }
50
51 /**
52 * @inheritdoc
53 */
54 get(key) {
55 return this._storage.get(key);
56 }
57
58 /**
59 * @inheritdoc
60 */
61 set(key, value) {
62 this._storage.set(key, value);
63 return this;
64 }
65
66 /**
67 * @inheritdoc
68 */
69 delete(key) {
70 this._storage.delete(key);
71 return this;
72 }
73
74 /**
75 * @inheritdoc
76 */
77 clear() {
78 this._storage.clear();
79 return this;
80 }
81
82 /**
83 * @inheritdoc
84 */
85 keys() {
86 return this._storage.keys();
87 }
88
89 /**
90 * @override
91 */
92 size() {
93 return this._storage.size;
94 }
95}
96exports.default = MapStorage;
97
98typeof $IMA !== 'undefined' && $IMA !== null && $IMA.Loader && $IMA.Loader.register('ima/storage/MapStorage', [], function (_export, _context) {
99 'use strict';
100 return {
101 setters: [],
102 execute: function () {
103 _export('default', exports.default);
104 }
105 };
106});