"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const quick_lru_1 = __importDefault(require("quick-lru"));
class LruCache {
    constructor(maxSize) {
        this.lru = new quick_lru_1.default({ maxSize });
    }
    get(key, valueFn) {
        const val = this.lru.get(key);
        // speed up by combining .has(key) and .get(key)
        if (val !== undefined) {
            return val;
        }
        const value = valueFn();
        this.lru.set(key, value);
        return value;
    }
}
exports.default = LruCache;
//# sourceMappingURL=lruCache.js.map