UNPKG

@prelude/function

Version:

Function module.

16 lines 389 B
const memoize = (f, k = JSON.stringify) => { const cache = new Map(); const f_ = (...args) => { const key = k(args); if (cache.has(key)) { return cache.get(key); } const r = f(...args); cache.set(key, r); return r; }; f_.cache = cache; return f_; }; export default memoize; //# sourceMappingURL=memoize.js.map