summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Federico Brigante <github@bfred.it> 2019-05-26 15:37:59 +0800
committerGravatar Federico Brigante <github@bfred.it> 2019-05-26 15:37:59 +0800
commitef3fce5ccc1c3350eb73e5c0a12ec1c9137d11fb (patch)
tree9a2030e5f39834e6a20b987f6f38674bcfc8be28
parentecb9919400463e5eb2381be95f538a28a98929e1 (diff)
downloadrefined-github-ef3fce5ccc1c3350eb73e5c0a12ec1c9137d11fb.tar.gz
refined-github-ef3fce5ccc1c3350eb73e5c0a12ec1c9137d11fb.tar.zst
refined-github-ef3fce5ccc1c3350eb73e5c0a12ec1c9137d11fb.zip
Replace `p-memoize` wrapper with `mem`19.5.26.1924
-rw-r--r--package-lock.json21
-rw-r--r--package.json1
-rw-r--r--source/globals.d.ts6
-rw-r--r--source/libs/api.ts6
-rw-r--r--source/libs/fetch-dom.ts7
5 files changed, 11 insertions, 30 deletions
diff --git a/package-lock.json b/package-lock.json
index 08930748..425f8ef5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9263,27 +9263,6 @@
"integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==",
"dev": true
},
- "p-memoize": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/p-memoize/-/p-memoize-3.1.0.tgz",
- "integrity": "sha512-e5tIvrsr7ydUUnxb534iQWtXxWgk/86IsH+H+nV4FHouIggBt4coXboKBt26o4lTu7JbEnGSeXdEsYR8BhAHFA==",
- "requires": {
- "mem": "^4.3.0",
- "mimic-fn": "^2.1.0"
- },
- "dependencies": {
- "mem": {
- "version": "4.3.0",
- "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz",
- "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==",
- "requires": {
- "map-age-cleaner": "^0.1.1",
- "mimic-fn": "^2.0.0",
- "p-is-promise": "^2.0.0"
- }
- }
- }
- },
"p-try": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
diff --git a/package.json b/package.json
index 1af22f00..88964f60 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,6 @@
"linkify-urls": "^2.2.0",
"mem": "github:sindresorhus/mem#10f13c0",
"onetime": "^5.0.0",
- "p-memoize": "^3.0.0",
"select-dom": "^5.1.0",
"shorten-repo-url": "^1.5.1",
"tiny-version-compare": "^1.0.0",
diff --git a/source/globals.d.ts b/source/globals.d.ts
index a1b757e2..8520f368 100644
--- a/source/globals.d.ts
+++ b/source/globals.d.ts
@@ -1,5 +1,11 @@
type AnyObject = Record<string, any>;
+// TODO: Drop after https://github.com/sindresorhus/p-memoize/issues/9
+declare module 'mem' {
+ function mem<T = VoidFunction>(fn: T): T;
+ export = mem;
+}
+
// TODO: Drop when Firefox adds RegEx lookbehind support
// https://github.com/sindresorhus/refined-github/pull/1936#discussion_r276515991
declare module 'linkify-urls' {
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);