1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.memoize = void 0;
|
4 | const defaultKey = 'default';
|
5 | function memoize(fn) {
|
6 | const cache = {};
|
7 | return (...args) => {
|
8 | const n = args[0] || defaultKey;
|
9 | if (n in cache) {
|
10 | return cache[n];
|
11 | }
|
12 | else {
|
13 | const result = fn(n === defaultKey ? undefined : n);
|
14 | cache[n] = result;
|
15 | return result;
|
16 | }
|
17 | };
|
18 | }
|
19 | exports.memoize = memoize;
|