|
1 | 1 | (function() {
|
2 | 2 | var Resolute = function(opt, callback) {
|
3 |
| - var self = this; |
4 | 3 | opt = opt || {};
|
5 | 4 | this.operation = opt.operation;
|
6 | 5 | this.maxRetry = opt.maxRetry || 3;
|
|
11 | 10 | Resolute.prototype.run = function(operation) {
|
12 | 11 | var self = this;
|
13 | 12 |
|
14 |
| - var checkForPromise = function(opt) { |
| 13 | + var _checkForPromise = function(opt) { |
15 | 14 | // Do we have a operation?
|
16 | 15 | var operation = (typeof opt === "undefined") ? this.operation : opt;
|
17 | 16 |
|
|
25 | 24 | }
|
26 | 25 | };
|
27 | 26 |
|
28 |
| - var fn = checkForPromise.call(self, operation); |
| 27 | + var _fn = _checkForPromise.call(self, operation); |
29 | 28 |
|
30 | 29 | var _delay = function(ms) {
|
31 | 30 | return new Promise(function(resolve, reject) {
|
|
34 | 33 | };
|
35 | 34 |
|
36 | 35 | var _retry = function(retryCount, maxRetry, fn, delay) {
|
37 |
| - retryCount = retryCount || 0; |
| 36 | + retryCount = retryCount || 1; |
38 | 37 | var retryMechanism = function(err) {
|
39 | 38 | if (retryCount >= maxRetry) {
|
40 | 39 | throw err;
|
|
49 | 48 | return fn.then(null, retryMechanism);
|
50 | 49 | };
|
51 | 50 |
|
52 |
| - return _retry(0, self.maxRetry, fn, self.delay); |
| 51 | + return _retry(1, self.maxRetry, _fn, self.delay); |
53 | 52 | };
|
54 | 53 |
|
55 | 54 | // CommonJS module
|
|
0 commit comments