New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

async-cache-dedupe

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-cache-dedupe - npm Package Compare versions

Comparing version

to
1.4.1

10

package.json
{
"name": "async-cache-dedupe",
"version": "1.4.0",
"version": "1.4.1",
"description": "An async deduping cache",

@@ -32,12 +32,12 @@ "main": "index.js",

"@fastify/pre-commit": "^2.0.2",
"ioredis": "^5.0.1",
"ioredis": "^5.2.3",
"proxyquire": "^2.1.3",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tap": "^16.2.0"
"tap": "^16.3.0"
},
"dependencies": {
"abstract-logging": "^2.0.1",
"mnemonist": "^0.39.0",
"safe-stable-stringify": "^2.2.0"
"mnemonist": "^0.39.2",
"safe-stable-stringify": "^2.3.1"
},

@@ -44,0 +44,0 @@ "standard": {

@@ -264,6 +264,10 @@ 'use strict'

let references = this.references(args, key, result)
if (references && typeof references.then === 'function') { references = await references }
// TODO validate references?
await this.storage.set(storageKey, result, this.ttl, references)
try {
let references = this.references(args, key, result)
if (references && typeof references.then === 'function') { references = await references }
// TODO validate references?
await this.storage.set(storageKey, result, this.ttl, references)
} catch (err) {
this.onError(err)
}

@@ -270,0 +274,0 @@ return result

@@ -494,2 +494,30 @@ 'use strict'

test('should handle references function (sync) throwing an error', async function (t) {
t.plan(4)
const cache = new Cache({ ttl: 60, storage: createStorage() })
cache.define('references', {
onError: (err) => { t.equal(err.message, 'boom') },
references: (args, key, result) => { throw new Error('boom') }
}, () => 'the-result')
t.equal(await cache.references(1), 'the-result')
t.equal(await cache.references(1), 'the-result')
})
test('should handle references function (async) throwing an error', async function (t) {
t.plan(4)
const cache = new Cache({ ttl: 60, storage: createStorage() })
cache.define('references', {
onError: (err) => { t.equal(err.message, 'boom') },
references: async (args, key, result) => { throw new Error('boom') }
}, () => 'the-result')
t.equal(await cache.references(1), 'the-result')
t.equal(await cache.references(1), 'the-result')
})
test('should cache with async references', async function (t) {

@@ -496,0 +524,0 @@ t.plan(1)