Minor changes here and there

This commit is contained in:
SukkaW
2024-02-06 15:49:51 +08:00
parent b7cae1061c
commit 7b2334ee3b
11 changed files with 37 additions and 82 deletions

View File

@@ -1,9 +1,5 @@
export const createMemoizedPromise = <T>(fn: () => Promise<T>, preload = true): () => Promise<T> => {
let promise: Promise<T> | null = null;
if (preload) {
promise = fn();
}
let promise: Promise<T> | null = preload ? fn() : null;
return () => {
promise ??= fn();