isaacs / node-lru-cache

A fast cache that automatically deletes the least recently used items
http://isaacs.github.io/node-lru-cache/
ISC License
5.35k stars 353 forks source link

Implement the Map interface #326

Closed alexgleason closed 9 months ago

alexgleason commented 10 months ago

I want to pass lru-cache into my custom class, which accepts any Map.

lru-cache and ttl-cache work perfectly in runtime, but I have to cast them using cache as Map<string, T>.

I added implements Map<K, V> to this class, and tweaked it to match. All it needed was a few type assertions, and the addition of [Symbol.toStringTag]. No functionality is changed.

alexgleason commented 9 months ago

@isaacs Bump

isaacs commented 9 months ago

Shipped on 10.2, thanks!

alexgleason commented 9 months ago

@isaacs Thank you!