Skip to content

Commit

Permalink
Merge pull request #9 from elliotttf/incorrect-apply
Browse files Browse the repository at this point in the history
Use call instead of apply for cached results.
  • Loading branch information
BryanDonovan committed Sep 10, 2014
2 parents 44c3711 + e0c011d commit 4c20114
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/caching.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var caching = function (args) {
if (err && (!self.ignoreCacheErrors)) {
cb(err);
} else if (result) {
cb.apply(null, result);
cb.call(cb, null, result);
} else if (self.queues[key]) {
self.queues[key].push(cb);
} else {
Expand All @@ -50,7 +50,8 @@ var caching = function (args) {
if (work_args[0]) { // assume first arg is an error
return cb(work_args[0]);
}
self.store.set(key, work_args, function (err) {
// Subsequently assume second arg is result.
self.store.set(key, work_args[1], function (err) {
if (err && (!self.ignoreCacheErrors)) {
return cb(err);
}
Expand Down

0 comments on commit 4c20114

Please sign in to comment.