===== ISTEM =====
Solve the following programming task.

TASK: Memoize Function Results

Write a pure 'memoize(fn)' wrapper that returns the cached result for the same arguments instead of recomputing it.

STARTER CODE (javascript):
function memoize(fn) {
  // Write your code here
}

module.exports = { memoize };


RULES:
- Keep the function name and signature EXACTLY as given.
- Return working code only. No explanations.
- Put the code in a single ``` block.
- Try to solve it first. If you genuinely cannot, write only this single
  line instead of producing faulty code: CANNOT_SOLVE

===== HAM YANIT =====
```javascript
function memoize(fn) {
  const cache = new Map();

  return function (...args) {
    const key = JSON.stringify(args);
    if (cache.has(key)) {
      return cache.get(key);
    }
    const result = fn.apply(this, args);
    cache.set(key, result);
    return result;
  };
}

module.exports = { memoize };
```