From 9e20661bb8095a669fe9e6c4033c4dbd3bed9b9b Mon Sep 17 00:00:00 2001 From: Sofian Hnaide Date: Tue, 20 Apr 2021 13:13:43 -0700 Subject: [PATCH] add getKey and forgetKey API's to optimism --- package.json | 1 + patches/optimism+0.15.0.patch | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 patches/optimism+0.15.0.patch diff --git a/package.json b/package.json index 660ad8306b5..0bb14ee0b00 100644 --- a/package.json +++ b/package.json @@ -113,6 +113,7 @@ "jest-fetch-mock": "^3.0.3", "jest-junit": "12.0.0", "lodash": "4.17.21", + "patch-package": "6.4.7", "react": "17.0.1", "react-dom": "17.0.1", "recast": "0.20.4", diff --git a/patches/optimism+0.15.0.patch b/patches/optimism+0.15.0.patch new file mode 100644 index 00000000000..0834f6676e5 --- /dev/null +++ b/patches/optimism+0.15.0.patch @@ -0,0 +1,47 @@ +diff --git a/node_modules/optimism/lib/bundle.cjs.js b/node_modules/optimism/lib/bundle.cjs.js +index 26e4f9e..eaf15bf 100644 +--- a/node_modules/optimism/lib/bundle.cjs.js ++++ b/node_modules/optimism/lib/bundle.cjs.js +@@ -458,6 +458,12 @@ function wrap(originalFunction, options) { + var key = makeCacheKey.apply(null, arguments); + return key !== void 0 && cache.delete(key); + }; ++ optimistic.getKey = function () { ++ return makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments); ++ }; ++ optimistic.forgetKey = function (key) { ++ return key !== void 0 && cache.delete(key); ++ }; + return optimistic; + } + +diff --git a/node_modules/optimism/lib/bundle.esm.js b/node_modules/optimism/lib/bundle.esm.js +index 02bc3e5..05e30fc 100644 +--- a/node_modules/optimism/lib/bundle.esm.js ++++ b/node_modules/optimism/lib/bundle.esm.js +@@ -456,6 +456,12 @@ function wrap(originalFunction, options) { + var key = makeCacheKey.apply(null, arguments); + return key !== void 0 && cache.delete(key); + }; ++ optimistic.getKey = function () { ++ return makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments); ++ }; ++ optimistic.forgetKey = function (key) { ++ return key !== void 0 && cache.delete(key); ++ }; + return optimistic; + } + +diff --git a/node_modules/optimism/lib/index.d.ts b/node_modules/optimism/lib/index.d.ts +index e945216..5676430 100644 +--- a/node_modules/optimism/lib/index.d.ts ++++ b/node_modules/optimism/lib/index.d.ts +@@ -8,6 +8,8 @@ export declare type OptimisticWrapperFunction void; + peek: (...args: TKeyArgs) => TResult | undefined; + forget: (...args: TKeyArgs) => boolean; ++ getKey: (...args: TArgs) => any; ++ forgetKey: (key: any) => boolean; + }; + export declare type OptimisticWrapOptions = { + max?: number;