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AK,GAE/B,CACA,YAAA,CAAa,EAAK,GACd,KAAK,MAAM,IAAI,EAAK,GACpB,KAAK,OACD,KAAK,MAAQ,KAAK,QAClB,KAAK,KAAO,EACZ,KAAK,OAAS,KAAK,MACnB,KAAK,MAAQ,IAAI,IAEzB,CACA,MAAA,CAAO,GACH,GAAI,KAAK,MAAM,IAAI,IAAQ,KAAK,OAAO,IAAI,GAAM,CAE7C,YAAgB,IADH,KAAK,IAAI,EAE1B,CACA,OAAO,CACX,CACA,GAAA,CAAI,GACA,OAAO,KAAK,OAAO,EACvB,CACA,IAAA,GACI,MAAO,CACH,MAAO,KAAK,UACZ,KAAM,KAAK,WAAc,KAAK,UAAY,KAAK,YAAe,GAEtE,EAEJ,QAAQ,IAAM,IACd,QAAQ,QAAU","file":"/npm/@zcorky/lru@1.0.5/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@zcorky/lru@1.0.5/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.lru = void 0;\nfunction getNow() {\n    return Date.now();\n}\nclass lru {\n    constructor(limit = 10) {\n        this.limit = limit;\n        this.size = 0;\n        this.cache = new Map();\n        this._cache = new Map();\n        this._hitCount = 0;\n        this._missCount = 0;\n    }\n    static create(limit) {\n        return new lru(limit);\n    }\n    get(key, option) {\n        let item = this.cache.get(key);\n        const maxAge = option && option.maxAge;\n        if (item) {\n            if (item.expired && getNow() > item.expired) {\n                this._missCount++;\n                item.expired = 0;\n                item.value = undefined;\n            }\n            else {\n                this._hitCount++;\n                if (maxAge !== undefined) {\n                    const expired = maxAge ? getNow() + maxAge : 0;\n                    item.expired = expired;\n                }\n            }\n            return item.value;\n        }\n        item = this._cache.get(key);\n        if (item) {\n            if (item.expired && getNow() > item.expired) {\n                this._missCount++;\n                item.expired = 0;\n                item.value = undefined;\n            }\n            else {\n                this._hitCount++;\n                this._updateCache(key, item);\n                if (maxAge !== undefined) {\n                    const expired = maxAge ? getNow() + maxAge : 0;\n                    item.expired = expired;\n                }\n            }\n            return item.value;\n        }\n        this._missCount++;\n    }\n    set(key, value, option) {\n        const maxAge = option && option.maxAge;\n        const expired = maxAge ? getNow() + maxAge : 0;\n        let item = this.cache.get(key);\n        if (item) {\n            item.expired = expired;\n            item.value = value;\n        }\n        else {\n            item = { expired, value };\n            this._updateCache(key, item);\n        }\n    }\n    _updateCache(key, item) {\n        this.cache.set(key, item);\n        this.size++;\n        if (this.size >= this.limit) {\n            this.size = 0;\n            this._cache = this.cache;\n            this.cache = new Map();\n        }\n    }\n    hasKey(key) {\n        if (this.cache.has(key) || this._cache.has(key)) {\n            const data = this.get(key);\n            return data !== undefined;\n        }\n        return false;\n    }\n    has(key) {\n        return this.hasKey(key);\n    }\n    hits() {\n        return {\n            count: this._hitCount,\n            rate: this._hitCount / ((this._hitCount + this._missCount) || 1),\n        };\n    }\n}\nexports.lru = lru;\nexports.default = lru;\n"]}