We need to improve the if statement in the cache check to: if (promiseCache.promiseFn === promise && deepEqual(inputs, promiseCache.inputs))
Example of an invalid case:
const fn1 = () => { ... }
const fn2 = () => { ... }
// Because both functions have the same parameter
// so the deepEqual can not guarantee the correct cache
To do so, when construct the cache item, you need to save the promiseFn as well:
const promiseCache: PromiseCache = {
promiseFn: promise,
promise:
...
};
We need to improve the if statement in the cache check to:
if (promiseCache.promiseFn === promise && deepEqual(inputs, promiseCache.inputs))Example of an invalid case:
To do so, when construct the cache item, you need to save the promiseFn as well: