1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.cacheWrapper = cacheWrapper;
|
7 | exports.cacheWrapperSync = cacheWrapperSync;
|
8 |
|
9 | async 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 |
|
21 | function 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 |
|
\ | No newline at end of file |