lru-cache-ext
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -12,6 +12,6 @@ import assert from 'assert'; | ||
async memoize(key, valueFn) { | ||
async memoize(key, valueFn, ...args) { | ||
assert(typeof valueFn === 'function'); | ||
if (!this.has(key)) { | ||
this.set(key, valueFn()); | ||
this.set(key, valueFn(args)); | ||
} | ||
@@ -30,6 +30,6 @@ try { | ||
memoizeSync(key, valueFn) { | ||
memoizeSync(key, valueFn, ...args) { | ||
assert(typeof valueFn === 'function'); | ||
if (!this.has(key)) { | ||
const r = valueFn(); | ||
const r = valueFn(args); | ||
assert(!(r instanceof Promise), 'Use memoize() instead'); | ||
@@ -36,0 +36,0 @@ this.set(key, r); |
{ | ||
"name": "lru-cache-ext", | ||
"type": "module", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Thin wrapper around lru-cache with extended functionality.", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -35,3 +35,3 @@ # lru-cache-ext | ||
### memoize(key: String, valueFn: function) | ||
### memoize(key: String, valueFn: function, ...args) | ||
@@ -46,3 +46,3 @@ Only when the key is not present in cache (or has expired), `valueFn` is called and placed into cache. | ||
### memoizeSync(key: String, valueFn: function) | ||
### memoizeSync(key: String, valueFn: function, ...args) | ||
@@ -49,0 +49,0 @@ Similar to "memoize", when key is not present (or has expired), `valueFn` is called and placed into the cache. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6653