sindresorhus/quick-lru

feat: if third argument is a number to `set(key, value, opts || maxAge)`, then assume it is `maxAge`

titanism opened this issue · 3 comments

In

set(key, value, {maxAge = this.maxAge} = {}) {
you can see that the third argument must be an object. However for 1:1 compatibility with other stores, e.g. ioredis, it would be nice (and backwards compatible) if you pass a third argument that is not an Object, but a Number. If a Number, it would be inferred as options.maxAge value.

@sindresorhus please see #43! 🎉

Current workaround until this PR is merged and released to npm:

const cache = new QuickLRU(this.options.quickLRU);
const set = cache.set;
cache.set = function(key, value, maxAge) {
  set.call(cache, key, value, { maxAge });
}

I'm not interested in this, sorry. I don't want my API to be worse just to be compatible with another random package.