title: Lodash memoize key when the function being memoized accepts functions?
body: <p>I have a large data collection that I frequently query by first applying a filter to it. I want to cache and reuse the results of the different filter functions I use because this part can be expensive. Here's a rough simulation of this:</p>
  
  <pre><code>const a = x =&gt; x + 1;
  const b = x =&gt; x + 2;
  
  const m = _.memoize( 
    f =&gt; (console.log('filtering data'), f(314159)),
    f =&gt; String(f)
   );
  
  console.log(m(a));
  console.log(m(b));
  console.log(m(a));
  console.log(m(b));
  </code></pre>
  
  <p>Here "a" and "b" would be the filter functions I want to use and "m" is acting on the same data each time. </p>
  
  <p>How do I specify the key for the _.memoize function?</p>
  
  <p>The above works but I'm using the string representation of the function which feels wrong. Is there a better way?</p>
  
  <p>I'm worried this isn't safe when minification is applied. In my actual code, the "memoize" part is in one ES6 module, the "a" and "b" parts are in another module and the calls to "m" are in several different modules which import the "a" and "b" function. Will the string representation be stable across modules like this? Is converting to the string representation fast?</p>
  
  <p>The only alternative I can think of is to create a string -> function dictionary so you would do calls like m("a") but JavaScript linters won't pick up if the name is wrong.</p>