diff options
Diffstat (limited to 'source/libs')
-rw-r--r-- | source/libs/api.ts | 6 | ||||
-rw-r--r-- | source/libs/fetch-dom.ts | 7 |
2 files changed, 5 insertions, 8 deletions
diff --git a/source/libs/api.ts b/source/libs/api.ts index 3bd87c0a..bf5e9149 100644 --- a/source/libs/api.ts +++ b/source/libs/api.ts @@ -24,7 +24,7 @@ it lets you define accept error HTTP codes as a valid response, like: so the call will not throw an error but it will return as usual. */ -import pMemoize from 'p-memoize'; +import mem from 'mem'; import OptionsSync from 'webext-options-sync'; import {JsonObject} from 'type-fest'; @@ -70,7 +70,7 @@ const v3defaults: GHRestApiOptions = { body: undefined }; -export const v3 = pMemoize(async ( +export const v3 = mem(async ( query: string, options: GHRestApiOptions = v3defaults ): Promise<AnyObject> => { @@ -98,7 +98,7 @@ export const v3 = pMemoize(async ( throw getError(apiResponse); }); -export const v4 = pMemoize(async (query: string): Promise<AnyObject> => { +export const v4 = mem(async (query: string): Promise<AnyObject> => { const {personalToken} = await settings; if (!personalToken) { diff --git a/source/libs/fetch-dom.ts b/source/libs/fetch-dom.ts index f1a921fe..251c20af 100644 --- a/source/libs/fetch-dom.ts +++ b/source/libs/fetch-dom.ts @@ -1,8 +1,5 @@ import domify from 'doma'; -import pMemoize from 'p-memoize'; - -// TODO: wait for https://github.com/sindresorhus/p-memoize/issues/9 -const memo = pMemoize as <T = VoidFunction>(fn: T) => T; +import mem from 'mem'; async function fetchDom(url: string): Promise<DocumentFragment>; async function fetchDom<TElement extends Element>(url: string, selector: string): Promise<TElement>; @@ -13,4 +10,4 @@ async function fetchDom(url: string, selector?: string): Promise<Node> { return selector ? dom.querySelector(selector)! : dom; } -export default memo(fetchDom); +export default mem(fetchDom); |