cache.js 872 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. /**
  4. * k-v 存储
  5. */
  6. var default_1 = /** @class */ (function () {
  7. function default_1() {
  8. this.map = {};
  9. }
  10. default_1.prototype.has = function (key) {
  11. return this.map[key] !== undefined;
  12. };
  13. default_1.prototype.get = function (key, def) {
  14. var v = this.map[key];
  15. return v === undefined ? def : v;
  16. };
  17. default_1.prototype.set = function (key, value) {
  18. this.map[key] = value;
  19. };
  20. default_1.prototype.clear = function () {
  21. this.map = {};
  22. };
  23. default_1.prototype.delete = function (key) {
  24. delete this.map[key];
  25. };
  26. default_1.prototype.size = function () {
  27. return Object.keys(this.map).length;
  28. };
  29. return default_1;
  30. }());
  31. exports.default = default_1;
  32. //# sourceMappingURL=cache.js.map