async-deco
Advanced tools
Comparing version 5.0.1 to 5.0.2
{ | ||
"name": "async-deco", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "A collection of decorators for adding features to asynchronous functions (callback or promise based).", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -176,2 +176,3 @@ async-deco | ||
* "cache-miss" (when the item is not in the cache) with {key: cache key} | ||
* "cache-set" with {args: arguments for caching, res: result to cache} | ||
@@ -248,2 +249,3 @@ Proxy | ||
* "fallback-cache-miss" with {key: cache key, actualResult: {err: error returned, res: result returned}} | ||
* "fallback-cache-set" with {args: arguments for caching, res: result to cache} | ||
@@ -250,0 +252,0 @@ Timeout |
@@ -26,2 +26,3 @@ var defaultLogger = require('../utils/default-logger'); | ||
if (!err) { | ||
logger('cache-set', {args: args, res: res}); | ||
cache.push(args, res); | ||
@@ -28,0 +29,0 @@ } |
@@ -11,3 +11,3 @@ var defaultLogger = require('../utils/default-logger'); | ||
if (error === Error || Error.isPrototypeOf(error)) { | ||
condition = function (err, dep) { return err instanceof error; }; | ||
condition = function (err, res) { return err instanceof error; }; | ||
} | ||
@@ -25,17 +25,17 @@ else { | ||
args[args.length - 1] = function (err, dep) { | ||
if (condition(err, dep)) { | ||
args[args.length - 1] = function (err, res) { | ||
if (condition(err, res)) { | ||
cache.query(args, function (e, cacheQuery) { | ||
if (e) { | ||
logger('fallback-cache-error', {err: err, cacheErr: e}); | ||
cb(err, dep); | ||
cb(err, res); | ||
} | ||
else if (cacheQuery.cached === true && | ||
(!cacheQuery.stale || (useStale && cacheQuery.stale))) { | ||
logger('fallback-cache-hit', {key: cacheQuery.key, result: cacheQuery, actualResult: {err: err, res: dep}}); | ||
logger('fallback-cache-hit', {key: cacheQuery.key, result: cacheQuery, actualResult: {err: err, res: res}}); | ||
cb(null, cacheQuery.hit); | ||
} | ||
else { | ||
logger('fallback-cache-miss', {key: cacheQuery.key, actualResult: {err: err, res: dep}}); | ||
cb(err, dep); | ||
logger('fallback-cache-miss', {key: cacheQuery.key, actualResult: {err: err, res: res}}); | ||
cb(err, res); | ||
} | ||
@@ -45,4 +45,8 @@ }); | ||
else { | ||
!noPush && cache.push(args, dep); | ||
cb(null, dep); | ||
if (!noPush) { | ||
logger('fallback-cache-set', {args: args, res: res}); | ||
cache.push(args, res); | ||
} | ||
cb(null, res); | ||
} | ||
@@ -49,0 +53,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98129
2646
513