Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions lib/backoff/linear.js
Original file line number Diff line number Diff line change
@@ -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: () => {} };
};