You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
612 B

3 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.cacheWrapper = cacheWrapper;
  6. exports.cacheWrapperSync = cacheWrapperSync;
  7. async function cacheWrapper(cache, key, fn) {
  8. const cached = cache.get(key);
  9. if (cached !== undefined) {
  10. return cached;
  11. }
  12. const result = await fn();
  13. cache.set(key, result);
  14. return result;
  15. }
  16. function cacheWrapperSync(cache, key, fn) {
  17. const cached = cache.get(key);
  18. if (cached !== undefined) {
  19. return cached;
  20. }
  21. const result = fn();
  22. cache.set(key, result);
  23. return result;
  24. }
  25. //# sourceMappingURL=cacheWrapper.js.map