Comparing version 0.0.6-7 to 0.0.7-1
@@ -48,3 +48,3 @@ exports.RETRY_STRATEGY = RETRY_STRATEGY = {CONSTANT: 0, EXPONENTIAL: 1, LINEAR: 2}; | ||
Re.prototype.try = function(operation, callback){ | ||
var fail = this.createFailCallback(operation, callback); | ||
var fail = this.createFailCallback(operation, callback, this.try); | ||
@@ -56,14 +56,13 @@ try{ | ||
} | ||
} | ||
}; | ||
Re.prototype.do = function(operation, callback){ | ||
var fail = this.createFailCallback(operation, callback); | ||
var fail = this.createFailCallback(operation, callback, this.do); | ||
operation(this.retry, fail, callback); | ||
} | ||
}; | ||
Re.prototype.createFailCallback = function(operation, callback){ | ||
Re.prototype.createFailCallback = function(operation, callback, method){ | ||
var self = this; | ||
return function(err){ | ||
var fail = self.createFailCallback(operation, callback); | ||
@@ -74,3 +73,3 @@ callback = callback || function () {}; | ||
setTimeout(function(){ | ||
operation(self.retry, fail, callback); | ||
method.call(self, operation, callback); | ||
}, | ||
@@ -77,0 +76,0 @@ self.retryInterval(self.retry)); |
{ | ||
"name": "re", | ||
"description": "Do it again, after a bit.", | ||
"version": "0.0.6-7", | ||
"version": "0.0.7-1", | ||
"main": "./lib/re", | ||
@@ -6,0 +6,0 @@ "keywords": ["utility", "retry", "exponential backoff", "linear backoff"], |
@@ -19,3 +19,3 @@ var retry = require('../lib/re'); | ||
last = now; | ||
if(retryCount < 10) fail(new Error("Not there yet.")); | ||
if(retryCount < 10) throw new Error("Not there yet."); | ||
else callback(null, retryCount); | ||
@@ -22,0 +22,0 @@ }, |
8559
112