UNPKG

@prelude/function

Version:

Function module.

18 lines 469 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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_; }; exports.default = memoize; //# sourceMappingURL=memoize.js.map