@keyvhq/memoize
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://keyv.js.org", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"main": "src/index.js", | ||
@@ -54,3 +54,3 @@ "author": { | ||
}, | ||
"gitHead": "f4e5470ed333a0bf2edabf03f28413fd0176cf51" | ||
"gitHead": "974af9fd536e632cf9817d376ea8b592fd0cb6f3" | ||
} |
@@ -149,3 +149,3 @@ # @keyvhq/memoize [<img width="100" align="right" src="https://ghcdn.rawgit.org/microlinkhq/keyv/master/media/logo-sunset.svg" alt="keyv">](https://github.com/microlinkhq/keyv) | ||
Type: `Number`<br/> | ||
Type: `Number` or `Function`<br/> | ||
Default: `undefined` | ||
@@ -155,2 +155,4 @@ | ||
When you provide a function, the value will be passed as first argument. | ||
##### ttl | ||
@@ -157,0 +159,0 @@ |
@@ -22,3 +22,8 @@ 'use strict' | ||
const ttl = typeof rawTtl === 'function' ? rawTtl : () => rawTtl | ||
const staleTtl = typeof rawStaleTtl === 'number' ? rawStaleTtl : undefined | ||
const staleTtl = | ||
typeof rawStaleTtl === 'function' | ||
? rawStaleTtl | ||
: typeof rawStaleTtl === 'number' | ||
? () => rawStaleTtl | ||
: undefined | ||
const pending = Object.create(null) | ||
@@ -79,3 +84,3 @@ | ||
const isStale = | ||
staleTtl !== undefined && hasExpires && ttlValue < staleTtl | ||
staleTtl !== undefined && hasExpires && ttlValue < staleTtl(data.value) | ||
const info = { hasValue, key, isExpired, isStale } | ||
@@ -82,0 +87,0 @@ const done = value => (objectMode ? [value, info] : value) |
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
9870
104
176