From 38d84c35bf721bda0e86d44eff0b6b339c230c12 Mon Sep 17 00:00:00 2001 From: Jo Liss Date: Wed, 6 Mar 2024 12:36:02 +0000 Subject: [PATCH] Use TypeScript's Awaited utility type instead of our custom EnsurePromise type --- README.md | 4 +--- src/index.ts | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1e746fd..26b2b1d 100755 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ export default function buildMemoizer( fn: unknown>( fn: FN, opt?: Partial - ) => Promise<(...args: Parameters) => EnsurePromise>> + ) => Promise<(...args: Parameters) => Promise>>> getCacheFilePath: ( fn: (...args: never) => unknown, args: unknown[], @@ -164,8 +164,6 @@ export default function buildMemoizer( ) => string invalidate: (cacheId?: string) => Promise } - -type EnsurePromise = T extends PromiseLike ? T : Promise; ``` ## Options diff --git a/src/index.ts b/src/index.ts index 0177c99..e278572 100644 --- a/src/index.ts +++ b/src/index.ts @@ -405,11 +405,9 @@ export default function buildMemoizer( await initCache(memoizerOptions.cachePath || '') return memoizeFn(fn as never, opt) as unknown as ( ...args: Parameters - ) => EnsurePromise> + ) => Promise>> }, getCacheFilePath: getCacheFilePathBound, invalidate: invalidateCache, } } - -type EnsurePromise = T extends PromiseLike ? T : Promise;