Store.js 953 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. var stores = {};
  2. /** @internal */
  3. var Store = /** @class */ (function () {
  4. function Store(kp) {
  5. this.kp = kp;
  6. this.data = {};
  7. }
  8. Store.resolve = function (kp) {
  9. if (!stores[kp]) {
  10. stores[kp] = new Store(kp);
  11. }
  12. return stores[kp];
  13. };
  14. Store.prototype.clear = function () {
  15. this.data = {};
  16. };
  17. Store.prototype.drop = function () {
  18. this.clear();
  19. delete stores[this.kp];
  20. };
  21. Store.prototype.get = function (key) {
  22. return this.data[key];
  23. };
  24. Store.prototype.key = function (idx) {
  25. return this.keys()[idx];
  26. };
  27. Store.prototype.keys = function () {
  28. return Object.keys(this.data);
  29. };
  30. Store.prototype.rm = function (k) {
  31. delete this.data[k];
  32. };
  33. Store.prototype.set = function (k, v) {
  34. this.data[k] = v;
  35. };
  36. return Store;
  37. }());
  38. export { Store };
  39. //# sourceMappingURL=Store.js.map