const memoize = func => { let cache = {}; return (...args) => { const key = JSON.stringify(args); if (!cache.hasOwnProperty(key)) { cache[key] = func(...args); } return cache[key]; }; }; module.exports = memoize;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter