cache.js 792 B

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