Uh oh!
There was an error while loading. Please reload this page.
chore!: bump lru-cache to 10.x & increase node engine - #695
Conversation
wraithgar
commented
Apr 7, 2024
This would need to be part of #501 since changing engines is a semver major. |
domoritz
commented
Apr 10, 2024
Node 16 is not supported anymore so maybe this doesn't need to be a breaking change? |
wraithgar
commented
Apr 10, 2024
Changing the engines to drop support for any node version, supported or not, is a breaking change for a package. |
domoritz
commented
Apr 10, 2024
Okay, a major version bump makes sense then. |
mbtools
commented
Apr 11, 2024
This package doesn't use any fancy features of How about we get rid of the dependency here and replace it with a simple class based on Map? classLRUCache{constructor(max=0){if(!Number.isInteger(max)||max<0)thrownewTypeError('max must be a nonnegative integer');this.max=max;this.map=newMap();}get(key){constvalue=this.map.get(key);if(value===undefined)returnundefined;else{// Remove the key from the map and add it to the endthis.map.delete(key);this.map.set(key,value);returnvalue;}}has(key){returnthis.map.has(key);}delete(key){if(this.map.has(key)){this.map.delete(key);returntrue;}elsereturnfalse;}set(key,value){constdeleted=this.delete(key);if(!deleted&&value!==undefined){// If cache is full, delete the least recently used itemif(this.map.size>=this.max){constfirstKey=this.map.keys().next().value;this.delete(firstKey);}this.map.set(key,value);}returnthis;}clear(){this.map.clear();}capacity(){returnthis.max;}size(){returnthis.map.size;}*entries(){for(const[key,value]ofthis.map)yield[key,value];}}exportdefaultLRUCache;I'm happy to provide a PR with 100% test coverage if you like. PS: You could also argue whether LRU is actually the best caching strategy. FIFO might be much faster for the majority of cases. But that's a different story. |
wraithgar
commented
Apr 11, 2024
On one hand it does seem like a simple Map cache is all we need and should be easy to implement. On the other hand "why don't you just" and "how hard can it be?" are usually hard lessons once one goes down the path of answering them. If it's not too much trouble, you can make that PR. I think that will inform a lot of our decision better than an academic discussion would. |
H4ad
commented
Apr 24, 2024
Closing in favor of #697 |
Trying to improve/solve the issue with dedupe on
cli: npm/cli#7350I don't know if it's a good idea since
semveris being used by a lot of projects and bumping the version ofnode-lru-cacherequires the bump ofengines.nodeto>=16, dropping a lot of node versions at once.