file-cache.js 925B

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var FileCache = (function () {
  4. function FileCache() {
  5. this.map = new Map();
  6. }
  7. FileCache.prototype.set = function (key, file) {
  8. file.timestamp = Date.now();
  9. this.map.set(key, file);
  10. };
  11. FileCache.prototype.get = function (key) {
  12. return this.map.get(key);
  13. };
  14. FileCache.prototype.has = function (key) {
  15. return this.map.has(key);
  16. };
  17. FileCache.prototype.remove = function (key) {
  18. var result = this.map.delete(key);
  19. return result;
  20. };
  21. FileCache.prototype.getAll = function () {
  22. var list = [];
  23. this.map.forEach(function (file) {
  24. list.push(file);
  25. });
  26. return list;
  27. };
  28. FileCache.prototype.getRawStore = function () {
  29. return this.map;
  30. };
  31. return FileCache;
  32. }());
  33. exports.FileCache = FileCache;