mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Improve fs memo (hash xxhash64)
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
const notError = Symbol('notError');
|
||||
|
||||
export function createMemoizedPromise<T>(fn: () => Promise<T>, preload = true): () => Promise<T> {
|
||||
export function createMemoizedPromise<T>(
|
||||
fn: () => Promise<T>,
|
||||
/** whether to create promise immediately or only create after first access */
|
||||
preload = true
|
||||
): () => Promise<T> {
|
||||
let error: Error | typeof notError = notError;
|
||||
|
||||
let promise: Promise<T> | null = preload
|
||||
|
||||
Reference in New Issue
Block a user