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

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

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