Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@keyvhq/memoize

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keyvhq/memoize - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

4

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://keyv.js.org",
"version": "1.2.4",
"version": "1.2.5",
"main": "src/index.js",

@@ -54,3 +54,3 @@ "author": {

},
"gitHead": "dd584d4305a5e81d076e7980fabd3b071a12f501"
"gitHead": "ed2f1e23632b9dd67dead0b775b0f17db6a1022f"
}

@@ -123,2 +123,14 @@ # @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)

The signature of the function should be a `String` to be used as key associated with the cache copy:
```js
key: ({req}) => req.url
```
Just in case you need a more granular control, you can return an `Array`, where the second value determines the expiration behavior:
```js
key: ({req}) => [req.url, req.query.forceExpiration]
```
##### objectMode

@@ -129,3 +141,3 @@

When is `true`, the result will be an Array, being the second item in the array some information about the item:
When is `true`, the result will be an `Array`, being the second item in the `Array` some information about the item:

@@ -132,0 +144,0 @@ ```js

@@ -73,3 +73,4 @@ 'use strict'

function memoized (...args) {
const key = getKey(...args)
const rawKey = getKey(...args)
const [key, forceExpiration] = Array.isArray(rawKey) ? rawKey : [rawKey]

@@ -86,6 +87,8 @@ if (!isUndefined(pending[key])) {

hasExpires && !isUndefined(staleTtl) ? staleTtl(data.value) : false
const isExpired = staleTtlValue === false && hasExpires && ttlValue < 0
const isExpired =
forceExpiration === true
? forceExpiration
: staleTtlValue === false && hasExpires && ttlValue < 0
const isStale = staleTtlValue !== false && ttlValue < staleTtlValue
const info = { hasValue, key, isExpired, isStale }
const info = { hasValue, key, isExpired, isStale, forceExpiration }
const done = value => (objectMode ? [value, info] : value)

@@ -92,0 +95,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc