Skip to content

Tag: caching

Memoize a curried function

Is it possible to memoize f with regard to the 2 arguments, namely: Answer You could take a Map as cache and take nested maps for all following arguments. This cache works for arbitrary count of arguments and reuses the values from the former calls. It works by taking a curried function and an optional Map. I…

Invalidate node cache when using Jest

I have a file with object that gets populated with process.env properties: env.js Now I try to test this file with different process.env properties: env.test.js Unfortunately, even though I try to load the file in every test separately the file gets loaded only once, making the third test fail with: P.S. It d…