UNPKG

@mrtkrcm/mcp-puppeteer

Version:

Model Context Protocol server for browser automation using Puppeteer

48 lines 1.57 kB
var LRUCache = /** @class */ (function () { function LRUCache(capacity) { this.cache = new Map(); this.keyOrder = []; this.capacity = capacity; } LRUCache.prototype.get = function (key) { var value = this.cache.get(key); if (value !== undefined) { // Move key to the end (most recently used) this.keyOrder = this.keyOrder.filter(function (k) { return k !== key; }); this.keyOrder.push(key); } return value; }; LRUCache.prototype.set = function (key, value) { if (this.cache.size >= this.capacity && !this.cache.has(key)) { // Evict least recently used item var lruKey = this.keyOrder.shift(); if (lruKey !== undefined) { this.cache.delete(lruKey); } } this.cache.set(key, value); // Update key order this.keyOrder = this.keyOrder.filter(function (k) { return k !== key; }); this.keyOrder.push(key); }; LRUCache.prototype.keys = function () { return this.cache.keys(); }; LRUCache.prototype.values = function () { return this.cache.values(); }; LRUCache.prototype.entries = function () { return this.cache.entries(); }; LRUCache.prototype.size = function () { return this.cache.size; }; LRUCache.prototype.clear = function () { this.cache.clear(); this.keyOrder = []; }; return LRUCache; }()); export { LRUCache }; //# sourceMappingURL=LRUCache.js.map