Skip to content

Commit

Permalink
Remove useless randomize code
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed May 15, 2011
1 parent 125c7e0 commit 332c633
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,12 @@ exports._createTimeout = function(attempt, opts) {
return opts.minTimeout;
}

var random = opts.randomize ? this._random(1, 2, 8) : 1;
var random = (opts.randomize)
? (Math.random() + 1)
: 1;

var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
timeout = Math.min(timeout, opts.maxTimeout);

return timeout;
}

exports._random = function(minVal, maxVal, floatVal) {
var randVal = minVal + Math.random() * (maxVal - minVal);
return typeof floatVal === 'undefined'
? Math.round(randVal)
: randVal.toFixed(floatVal);
}

0 comments on commit 332c633

Please sign in to comment.