Browse Source

Promisify getAndPassUp

feature/remove-domains
Jonathan 9 years ago
parent
commit
e45393a9e5
  1. 22
      lib/multi_caching.js

22
lib/multi_caching.js

@ -132,15 +132,15 @@ var multiCaching = function(caches, options) {
* @param {function} cb * @param {function} cb
*/ */
self.getAndPassUp = function(key, cb) { self.getAndPassUp = function(key, cb) {
return getFromHighestPriorityCache(key, function(err, result, index) { var promised = false;
if (err) { if (!cb) {
if (cb) { promised = true;
return cb(err); cb = Promise.defer();
} }
}
if (cb) { getFromHighestPriorityCache(key, function(err, result, index) {
cb(err, result); if (err) {
return (!promised) ? cb(err) : cb.reject(err);
} }
if (index) { if (index) {
@ -153,7 +153,13 @@ var multiCaching = function(caches, options) {
} }
}); });
} }
return (!promised) ? cb(err, result) : cb.resolve(result);
}); });
if (promised) {
return cb.promise;
}
}; };
/** /**

Loading…
Cancel
Save