Files
klz-cables.com/.pnpm-store/v10/files/a7/7b0bcc7379241cf3a8f59223410eb757df6ae60a8b16946bbb2f29ff57befc187d9cc383ef6dac057145fc7d41cc93e6673ac3ac7ef2c5761a58915bb8035b
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

67 lines
1.6 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/** A simple Least Recently Used map */
class LRUMap {
constructor( _maxSize) {this._maxSize = _maxSize;
this._cache = new Map();
}
/** Get the current size of the cache */
get size() {
return this._cache.size;
}
/** Get an entry or undefined if it was not in the cache. Re-inserts to update the recently used order */
get(key) {
const value = this._cache.get(key);
if (value === undefined) {
return undefined;
}
// Remove and re-insert to update the order
this._cache.delete(key);
this._cache.set(key, value);
return value;
}
/** Insert an entry and evict an older entry if we've reached maxSize */
set(key, value) {
if (this._cache.size >= this._maxSize) {
// keys() returns an iterator in insertion order so keys().next() gives us the oldest key
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const nextKey = this._cache.keys().next().value;
this._cache.delete(nextKey);
}
this._cache.set(key, value);
}
/** Remove an entry and return the entry if it was in the cache */
remove(key) {
const value = this._cache.get(key);
if (value) {
this._cache.delete(key);
}
return value;
}
/** Clear all entries */
clear() {
this._cache.clear();
}
/** Get all the keys */
keys() {
return Array.from(this._cache.keys());
}
/** Get all the values */
values() {
const values = [];
this._cache.forEach(value => values.push(value));
return values;
}
}
exports.LRUMap = LRUMap;
//# sourceMappingURL=lru.js.map