Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
612 bytes
|
Line | |
---|
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 | //# sourceMappingURL=cacheWrapper.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.