function cached(fn) {
  const cache = Object.create(null);
  return function (str) {
    const key = isPrimitive(str) ? str : JSON.stringify(str);
    const hit = cache[key];
    return hit || (cache[key] = fn(str));
  };
}
Create a cached version of fn that given an input string returns a
cached return value mapped from the string, regardless if fn is a new function every time.
created.
@param {*} fn The function call to be cached
@void