Huge News!Announcing our $40M Series B led by Abstract Ventures.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 1.12.0 to 2.0.0

6

index.d.ts

@@ -79,3 +79,3 @@ import { Redis } from "ioredis";

define<T extends (...args: any[]) => any, N extends string, S extends this>(
define<T extends (args: any) => any, N extends string, S extends this>(
name: N,

@@ -89,3 +89,3 @@ opts: {

references?: (
args: Parameters<T>,
args: Parameters<T>[0],
key: string,

@@ -97,3 +97,3 @@ result: Awaited<ReturnType<T>>

): S & { [n in N]: T };
define<T extends (...args: any[]) => any, N extends string, S extends this>(
define<T extends (args: any) => any, N extends string, S extends this>(
name: N,

@@ -100,0 +100,0 @@ opts: T

// Write a tsd file for the module
import { expectType } from "tsd";
import { expectType, expectError, expectNotAssignable, expectAssignable } from "tsd";
import { createCache, Cache, createStorage } from ".";

@@ -80,1 +80,25 @@ import { StorageInterface, StorageMemoryOptions } from "./index.js";

await unionMemoryCache.invalidateAll(["test:1", "test:2", "test:3"], "memory");
// Testing define.func only accepts one argument
const fetchFuncSingleArgument = async (args: {k1: string, k2:string}) => {
console.log("query", args.k1, args.k2);
return { k1: args.k1, k2: args.k2 };
};
const fetchFuncMultipleArguments = async (k1: string, k2:string) => {
console.log("query", k1, k2);
return { k1, k2 };
};
expectAssignable<Parameters<typeof unionMemoryCache.define>>(["fetchFuncSingleArgument", fetchFuncSingleArgument]);
expectNotAssignable<Parameters<typeof unionMemoryCache.define>>(["fetchFuncMultipleArguments", fetchFuncMultipleArguments]);
// Testing define.opts.references
memoryCache.define("fetchFuncSingleArgument", {
references: (args, key, result) => {
expectType<{ k1: string; k2: string }>(args);
return [];
}
}, fetchFuncSingleArgument);
{
"name": "async-cache-dedupe",
"version": "1.12.0",
"version": "2.0.0",
"description": "An async deduping cache",

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

"@fastify/pre-commit": "^2.0.2",
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-inject": "^5.0.3",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-node-resolve": "^15.2.1",
"browserify": "^17.0.0",
"buffer": "^6.0.3",
"esbuild": "^0.17.4",
"esbuild": "^0.19.4",
"esbuild-plugin-alias": "^0.2.1",
"events": "^3.3.0",
"ioredis": "^5.2.3",
"ioredis": "^5.3.2",
"path-browserify": "^1.0.1",
"playwright": "^1.29.2",
"playwright": "^1.38.1",
"process": "^0.11.10",
"proxyquire": "^2.1.3",
"rollup": "^3.11.0",
"rollup": "^3.29.4",
"rollup-plugin-polyfill-node": "^0.12.0",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"standard": "^17.1.0",
"stream-browserify": "^3.0.0",
"tap": "^16.3.0",
"tap-mocha-reporter": "^5.0.3",
"tap-parser": "^13.0.0",
"tape": "^5.6.3",
"tsd": "^0.26.1",
"vite": "^4.0.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
"tap": "^18.4",
"tap-mocha-reporter": "^5.0.4",
"tap-parser": "^15.2.0",
"tape": "^5.7.0",
"tsd": "^0.29.0",
"vite": "^4.4.9",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"mnemonist": "^0.39.2",
"safe-stable-stringify": "^2.3.1"
"mnemonist": "^0.39.5",
"safe-stable-stringify": "^2.4.3"
},

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

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

// istanbul ignore next
/* c8 ignore next */
const setImmediate = isServerSide ? globalThis.setImmediate : (fn, ...args) => setTimeout(fn, 0, ...args)

@@ -141,6 +141,6 @@

const keys = this.referencesKeys.get(reference)
// istanbul ignore next
/* c8 ignore next */
if (!keys) { continue }
const index = bsearchIndex(keys, key)
// istanbul ignore next
/* c8 ignore next */
if (index < 0) { continue }

@@ -244,3 +244,3 @@ keys.splice(index, 1)

this.log.debug({ msg: 'acd/storage/memory._removeReferencesKeys, get reference-key', reference, keys, referencesKeys })
// istanbul ignore next
/* c8 ignore next */
if (!referencesKeys) continue

@@ -304,3 +304,2 @@

this.log.debug({ msg: 'acd/storage/memory._invalidateReferences, remove key on reference', reference, key })
// istanbul ignore next
if (this._removeKey(key)) {

@@ -344,3 +343,2 @@ removed.push(key)

this.log.debug({ msg: 'acd/storage/memory._invalidateReference, remove key on reference', reference, key })
// istanbul ignore next
if (this._removeKey(key)) {

@@ -387,3 +385,2 @@ removed.push(key)

for (let i = 0; i < keys.length; i++) {
// istanbul ignore next
if (this._removeKey(keys[i])) {

@@ -414,3 +411,2 @@ removed.push(keys[i])

const timeout = setTimeout(_clearTimer, 1000)
// istanbul ignore next
if (typeof timeout.unref === 'function') timeout.unref()

@@ -417,0 +413,0 @@ return _timer

@@ -248,5 +248,3 @@ 'use strict'

test('should rejectes invalidating on non-existing storage', async (t) => {
t.plan(1)
test('should rejects invalidating on non-existing storage', async (t) => {
const cache = new Cache({

@@ -253,0 +251,0 @@ storage: {

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

test('should throw if is not server side and storage is redis', async (t) => {
const createStorageMock = t.mock('../src/storage/index.js', {
const createStorageMock = t.mockRequire('../src/storage/index.js', {
'../src/util.js': module.exports = {

@@ -1025,0 +1025,0 @@ isServerSide: false

Sorry, the diff of this file is not supported yet

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