UNPKG

612 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.cacheWrapper = cacheWrapper;
7exports.cacheWrapperSync = cacheWrapperSync;
8
9async function cacheWrapper(cache, key, fn) {
10 const cached = cache.get(key);
11
12 if (cached !== undefined) {
13 return cached;
14 }
15
16 const result = await fn();
17 cache.set(key, result);
18 return result;
19}
20
21function cacheWrapperSync(cache, key, fn) {
22 const cached = cache.get(key);
23
24 if (cached !== undefined) {
25 return cached;
26 }
27
28 const result = fn();
29 cache.set(key, result);
30 return result;
31}
32//# sourceMappingURL=cacheWrapper.js.map
\No newline at end of file