You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
544 B
19 lines
544 B
"use strict"; |
|
Object.defineProperty(exports, "__esModule", { value: true }); |
|
exports.memorizer = void 0; |
|
const defaultSize = 50000; |
|
function memorizer(fn, size = defaultSize) { |
|
const cache = new Map(); |
|
return (...args) => { |
|
const key = args.join('>!@['); |
|
if (!cache.has(key)) { |
|
if (cache.size >= size) { |
|
cache.clear(); |
|
} |
|
cache.set(key, fn(...args)); |
|
} |
|
return cache.get(key); |
|
}; |
|
} |
|
exports.memorizer = memorizer; |
|
//# sourceMappingURL=Memorizer.js.map
|