const hasher = require('node-object-hash')({ sort: true });
const pMemoize = require('p-memoize');

/**
 * @param { Function } The function to cache
 * @param { Object } cache. Default is new Map(). Must implement: .has(key), .get(key), .set(key, value), .delete(key), and optionally .clear().
 */
const cache = (fn, cache) => {
  return pMemoize(fn, {
    cacheKey: function(){
      return hasher.hash(arguments);
    },
    cache
  });
};

module.exports = cache;
@@ -319,15 +319,78 @@
 ache
+, getKey
 ) =%3E %7B%0A
+  getKey = getKey %7C%7C function()%7B return arguments; %7D;%0A%0A
   re
@@ -460,16 +460,23 @@
 er.hash(
+getKey(
 argument
@@ -477,16 +477,17 @@
 guments)
+)
 ;%0A    %7D,

Allow custom cache key