-
#1890
2bf1642
Thanks @belgattitude! - Rename getOrInsert into getOrSet (BC) -
#1890
2bf1642
Thanks @belgattitude! - LRU.clear now returns the number of cleared items -
#1890
2bf1642
Thanks @belgattitude! - Allow CacheKey type to be a number (still default to string) -
#1890
2bf1642
Thanks @belgattitude! - Export BaseCache interface for customization
- #1890
2bf1642
Thanks @belgattitude! - Add benchmarks for iterators and peek
-
#1875
0ace180
Thanks @belgattitude! - ~85 bytes size reductionBefore ~620 bytes, now ~535b compressed
-
#1875
a0b2c12
Thanks @belgattitude! - Move to native javascript private class properties (#)
-
#1875
0ace180
Thanks @belgattitude! - Small performance increase for peek() -
#1875
0ace180
Thanks @belgattitude! - Fix ensure proper reinitialization after calling clear
-
#1872
6b5c38e
Thanks @belgattitude! - Updated browserslist baseline for 2025For most users there won't be any change. Still around 95% on browserslist.
defaults chrome >= 96 firefox >= 105 edge >= 113 safari >= 15 ios >= 15 opera >= 103 not dead
-
#1866
59e5b25
Thanks @belgattitude! - Add getOrInsert methodconst lru = new LRUCache({ maxSize: 2 }); lru.set("key1", "value1"); lru.getOrInsert("key1", "value2"); // 👈 will not overwrite the value console.log(lru.get("key1")); // value1
-
#1866
fa3287a
Thanks @belgattitude! - Rename TinyLRU into LRUCache -
#1866
59e5b25
Thanks @belgattitude! - Add iterator symbolconst lru = new LRUCache({ maxSize: 2 }); lru.set("key1", "value1"); lru.set("key2", "value2"); lru.set("key3", "value3"); // trigger a get to move key2 to the head lru.get("key2"); const results = []; // iterate over the cache entries for (const [key, value] of lru) { results.push([key, value]); } expect(results).toStrictEqual([ ["key3", "value3"], // Least recently used ["key2", "value2"], // Most recently used ]);
-
#1866
59e5b25
Thanks @belgattitude! - Add onEviction callbackconst fn = vi.fn(); const lru = new LRUCacheLRU({ maxSize: 2, onEviction: (key, value) => { fn(key, value); }, }); lru.set("key1", "value1"); lru.set("key2", "value2"); lru.set("key3", "value3"); // 👈 Will evict key1 due to capacity expect(fn).toHaveBeenCalledExactlyOnceWith("key1", "value1");
76556f0
- Rename LRUCache in LRUCache
-
#1859
101e19e
Thanks @belgattitude! - Update browserslist minimumsdefaults chrome >= 96 firefox >= 94 edge >= 91 safari >= 14 ios >= 14 opera >= 83
- #1854
afcaf21
Thanks @belgattitude! - Initial lru implementation