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

async-cache-dedupe

Package Overview
Dependencies
Maintainers
1
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 0.2.0 to 0.3.0

2

index.js

@@ -87,3 +87,3 @@ 'use strict'

buildPromise (query, args, key) {
query.promise = this.func(args)
query.promise = this.func(args, key)
// we fork the promise chain on purpose

@@ -90,0 +90,0 @@ query.promise.catch(() => this.ids.set(key, undefined))

{
"name": "async-cache-dedupe",
"version": "0.2.0",
"version": "0.3.0",
"description": "An async deduping cache",

@@ -11,3 +11,3 @@ "main": "index.js",

"type": "git",
"url": "git+https://github.com/mcollina/async-dedupe-cache.git"
"url": "git+https://github.com/mcollina/async-cache-dedupe.git"
},

@@ -14,0 +14,0 @@ "keywords": [

@@ -56,3 +56,3 @@ # async-cache-dedupe

### `cache.define(name[, opts], original(arg))`
### `cache.define(name[, opts], original(arg, cacheKey))`

@@ -68,3 +68,4 @@ Define a new function to cache of the given `name`.

The `define` method adds a `cache[name]` function that will call the `original` function if the result is not present
in the cache. The cache key for `arg` is computed using [`safe-stable-stringify`](https://www.npmjs.com/package/safe-stable-stringify).
in the cache. The cache key for `arg` is computed using [`safe-stable-stringify`](https://www.npmjs.com/package/safe-stable-stringify)
and it is passed as the `cacheKey` argument to the original function.

@@ -71,0 +72,0 @@ ### `cache.clear([name], [arg])`

@@ -6,2 +6,3 @@ 'use strict'

const { AsyncLocalStorage } = require('async_hooks')
const stringify = require('safe-stable-stringify')

@@ -12,3 +13,3 @@ const kValues = require('../symbol')

// plan verifies that fetchSomething is called only once
t.plan(3)
t.plan(5)

@@ -19,4 +20,5 @@ const cache = new Cache()

cache.define('fetchSomething', async (query) => {
cache.define('fetchSomething', async (query, cacheKey) => {
t.equal(query, expected.shift())
t.equal(stringify(query), cacheKey)
return { k: query }

@@ -117,3 +119,3 @@ })

// plan verifies that fetchSomething is called only once
t.plan(3)
t.plan(5)

@@ -127,4 +129,6 @@ const cache = new Cache()

cache.define('fetchSomething', async (query) => {
cache.define('fetchSomething', async (query, cacheKey) => {
t.same(query, expected.shift())
t.equal(stringify(query), cacheKey)
return { k: query }

@@ -131,0 +135,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