feat: refactoring project
This commit is contained in:
19
node_modules/webpack/lib/util/memoize.js
generated
vendored
19
node_modules/webpack/lib/util/memoize.js
generated
vendored
@@ -14,20 +14,19 @@
|
||||
const memoize = fn => {
|
||||
let cache = false;
|
||||
/** @type {T | undefined} */
|
||||
let result = undefined;
|
||||
let result;
|
||||
return () => {
|
||||
if (cache) {
|
||||
return /** @type {T} */ (result);
|
||||
} else {
|
||||
result = fn();
|
||||
cache = true;
|
||||
// Allow to clean up memory for fn
|
||||
// and all dependent resources
|
||||
// eslint-disable-next-line no-warning-comments
|
||||
// @ts-ignore
|
||||
fn = undefined;
|
||||
return /** @type {T} */ (result);
|
||||
}
|
||||
|
||||
result = fn();
|
||||
cache = true;
|
||||
// Allow to clean up memory for fn
|
||||
// and all dependent resources
|
||||
/** @type {FunctionReturning<T> | undefined} */
|
||||
(fn) = undefined;
|
||||
return /** @type {T} */ (result);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user