Update memoize.md

This commit is contained in:
atomiks
2018-01-02 15:06:52 +11:00
committed by GitHub
parent 116f68d89d
commit 77d89d949c

View File

@ -9,7 +9,7 @@ Allow access to the `cache` by setting it as a property on the returned function
```js
const memoize = fn => {
const cache = new Map();
const cached = val => cache.get(val) || (cache.set(val, fn(val))) && cache.get(val);
const cached = val => cache.has(val) ? cache.get(val) : (cache.set(val, fn(val)) && cache.get(val));
cached.cache = cache;
return cached;
};