source: frontend/node_modules/schema-utils/dist/util/memorize.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 686 bytes
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7/**
8 * @template T
9 * @typedef {() => T} FunctionReturning
10 */
11
12/**
13 * @template T
14 * @param {FunctionReturning<T>} fn memorized function
15 * @returns {FunctionReturning<T>} new function
16 */
17const memoize = fn => {
18 let cache = false;
19 /** @type {T} */
20 let result;
21 return () => {
22 if (cache) {
23 return result;
24 }
25 result = fn();
26 cache = true;
27 // Allow to clean up memory for fn
28 // and all dependent resources
29 /** @type {FunctionReturning<T> | undefined} */
30 fn = undefined;
31 return result;
32 };
33};
34var _default = exports.default = memoize;
Note: See TracBrowser for help on using the repository browser.