diff --git a/lib/backoff/linear.js b/lib/backoff/linear.js index 6610ce2..091e501 100644 --- a/lib/backoff/linear.js +++ b/lib/backoff/linear.js @@ -1,18 +1,11 @@ -const get = require('lodash').get; - -module.exports = function (options) { - const min = get(options, 'min', 1000); - const max = get(options, 'max', min); +module.exports = function (options = {}) { + const min = options.min || 1000; + const max = options.max || min; + const range = max - min; function next() { - return Math.floor(Math.random() * (max - min + 1) + min); + return range === 0 ? min : Math.floor(Math.random() * (range + 1) + min); } - // eslint-disable-next-line no-empty-function - function reset() {} - - return { - next, - reset, - }; + return { next, reset: () => {} }; };