const memoized = fn => { const cache = new WeakMap() return (...args) => { if (!cache.has(args)) { cache.set(args, fn(...args)) } return cache.get(args) } }