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

async-deco

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-deco - npm Package Compare versions

Comparing version 8.1.0 to 8.1.1

2

package.json
{
"name": "async-deco",
"version": "8.1.0",
"version": "8.1.1",
"description": "A collection of decorators for adding features to asynchronous functions (callback or promise based).",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -234,6 +234,6 @@ async-deco

* an "error" attribute. This can be either an Error constructor function, or a function returning true if the result should be considered an error. The function takes as argument the output of the decorated function: error, result. If the result is an error the returned value is not cached.
* a "key" function: this function runs on the arguments of the decorated function and return a string. This string is used as cache key
* a "tags" function: this function runs on the arguments of the decorated function and return a list of tags. This string is used as surrogate key
* a "keys" function: this function runs on the arguments of the decorated function and return an array. This array is the list of keys to remove.
* a "tags" function: this function runs on the arguments of the decorated function and return a list of tags. These strings are used as surrogate keys
You can have either "tags" or "key". Not both.
You can have either "tags" or "keys". Not both.

@@ -240,0 +240,0 @@ Proxy

var defaultLogger = require('../utils/default-logger');
var getErrorCondition = require('./get-error-condition');
var keyGetter = require('memoize-cache-utils/key-getter');
var keysGetter = require('memoize-cache-utils/keys-getter');

@@ -9,3 +8,3 @@

var condition = getErrorCondition(opts.error);
var getCacheKey = keyGetter(opts.key);
var getCacheKeys = keysGetter(opts.keys);
var getTags = keysGetter(opts.tags);

@@ -17,3 +16,3 @@

var args = Array.prototype.slice.call(arguments, 0);
var key = getCacheKey.apply(this, args);
var keys = getCacheKeys.apply(this, args);
var tags = getTags.apply(this, args);

@@ -34,5 +33,5 @@ var logger = defaultLogger.apply(context);

});
} else if (key) {
cache.purgeByKeys(key, function () {
if (!catchingError(err)) logger('purge-cache', { key: key });
} else if (keys && Array.isArray(keys) && keys.length) {
cache.purgeByKeys(keys, function () {
if (!catchingError(err)) logger('purge-cache', { keys: keys });
});

@@ -39,0 +38,0 @@ }

@@ -13,2 +13,6 @@ var assert = require('chai').assert;

};
var getKeys = function (key) {
return [key];
};
var getTags = function () {

@@ -19,3 +23,3 @@ return ['tag'];

cached = cacheDecorator(cache);
purgeCache = purgeCacheDecorator(cache, { key: getKey });
purgeCache = purgeCacheDecorator(cache, { keys: getKeys });
purgeCacheByTags = purgeCacheDecorator(cache, { tags: getTags });

@@ -22,0 +26,0 @@ });

@@ -13,2 +13,5 @@ var assert = require('chai').assert;

};
var getKeys = function (key) {
return [key];
};
var getTags = function () {

@@ -19,3 +22,3 @@ return ['tag'];

cached = cacheDecorator(cache);
purgeCache = purgeCacheDecorator(cache, { key: getKey });
purgeCache = purgeCacheDecorator(cache, { keys: getKeys });
purgeCacheByTags = purgeCacheDecorator(cache, { tags: getTags });

@@ -22,0 +25,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