Share your code.
npm install memoize-async
memoize(fn: function [, keyGen: function]): Promise
- fn: function to evaluate (can be async or sync)
- keyGen: function used to generate a key from fn params, useful for complex memoization (can be async or sync)
memoize-asyncexpects the global
Promiseto be defined
const fn =const memFetch =// must resolve from fn// resolves from cache
const fn =const keyGen = useridconst memFetchUserProfile =const user =id: '1234-5678'profile: ''// sets cache key to '1234-5678'// resolves from cache
const url = ''const fn =const memFetch =const CLEAR_TIMER = 1000 * 60 * 5// also
npm test. To also generate coverage run
npm run test:coverage.