UNPKG

1.4 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var RegistryMap = /** @class */ (function () {
4 function RegistryMap(entries) {
5 if (entries === void 0) { entries = []; }
6 this.map = new Map(entries);
7 }
8 Object.defineProperty(RegistryMap.prototype, "keys", {
9 get: function () {
10 return Array.from(this.map.keys());
11 },
12 enumerable: true,
13 configurable: true
14 });
15 RegistryMap.prototype.clear = function () {
16 this.map.clear();
17 };
18 RegistryMap.prototype.register = function (key, value) {
19 if (this.map.has(key) === false) {
20 this.map.set(key, []);
21 }
22 var collection = this.resolve(key);
23 collection.push(value);
24 this.map.set(key, collection);
25 };
26 RegistryMap.prototype.remove = function (key, value) {
27 if (this.map.has(key)) {
28 var collection = this.resolve(key);
29 var index = collection.indexOf(value);
30 collection.splice(index, 1);
31 }
32 };
33 RegistryMap.prototype.reset = function (key) {
34 if (this.map.has(key)) {
35 this.map.set(key, []);
36 }
37 };
38 RegistryMap.prototype.resolve = function (key) {
39 return this.map.get(key) || [];
40 };
41 return RegistryMap;
42}());
43exports.RegistryMap = RegistryMap;
44//# sourceMappingURL=RegistryMap.js.map
\No newline at end of file