Files
lobehub__lobehub/tests/mocks/lru_map.ts
Innei ae499c9ab9 ✨ feat: improve PageEditor header UX with DropdownMenu and i18n support (#11462)
* ✨ feat: improve PageEditor header UX with DropdownMenu and i18n support

- Migrate Header from Dropdown to DropdownMenu component with checkbox support
- Add i18n for Ask Copilot item using common cmdk.askLobeAI key
- Replace BotIcon with Avatar using DEFAULT_INBOX_AVATAR
- Add hideWhenExpanded prop to ToggleRightPanelButton
- Conditionally show page info section only when lastUpdatedTime exists

* 🔧 chore: update @lobehub/ui dependency to version 4.18.0 in package.json

* feat: unify proxy setting style

Signed-off-by: Innei <tukon479@gmail.com>

* fix: test

Signed-off-by: Innei <tukon479@gmail.com>

* fix: test

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-01-13 18:25:28 +08:00

41 lines
715 B
TypeScript

class LRUMap<K, V> {
private map = new Map<K, V>();
private limit: number;
constructor(limit = 0) {
this.limit = limit;
}
get size() {
return this.map.size;
}
get(key: K) {
return this.map.get(key);
}
set(key: K, value: V) {
if (!this.map.has(key) && this.limit > 0 && this.map.size >= this.limit) {
const oldest = this.map.keys().next().value as K | undefined;
if (oldest !== undefined) this.map.delete(oldest);
}
this.map.set(key, value);
return this;
}
delete(key: K) {
const value = this.map.get(key);
this.map.delete(key);
return value;
}
clear() {
this.map.clear();
}
}
export { LRUMap };
export default { LRUMap };