rsms/js-lru

Make this an npm module

calebmer opened this issue · 6 comments

I'd like to use this module in node. For now I'd have to use a git submodule or copy/paste the code. Could this be made into an npm module?

All that would need to be done is use commonjs (or umd) to export the LRUCache, run npm init (make sure the package.json main property is lru.js), and then npm publish.

A few recommended package names that aren't taken would be:

  • least-recently-used
  • lru-algorithm

👍

I just stumbled on something really cool. @yyx990803 of the Vue JavaScript front end framework has added a copy of this cache in his framework (see).

@calebmer FYI there's a widely used LRU cache node package: https://github.com/isaacs/node-lru-cache

I'm aware, but after doing research on all the LRU-* js implementations I trust this one the most. It also happens to be the only one with performance benchmarks.

It might be worth asking, even if there are other good implementations, why this one?

rsms commented

FTR, this code has been or is still being used at Spotify, Facebook and Dropbox. It was created a long time ago with the intention to be portable, simple and just useful.

For these reasons I think it's too small for being a NPM module — you really should just copy whatever parts of lru.js you need.

However, publishing an NPM package takes 30 seconds (which might explain the low quality of NPM, hint hint), so I've done just that.

Hope it helps