Skip to content

Commit

Permalink
Fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
eoboite committed Jan 2, 2019
1 parent d1bb594 commit e168a10
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ const sleep = async(time) => {
* @returns {number} - A random number converted to seconds
*/
const randomTime = (options) => {
if (!_.isNil(options) && _.gt(options.min, options.max)) {
throw new RangeError("Min value can't be greater than max");
}

if (!_.isNil(options) && _.eq(options.min, options.max)) {
throw new RangeError("Min time can't equal Max time");
}

const defaults = _.merge({}, { min: 5, max: 7 }, options);
return _.random(defaults.min, defaults.max) * 1000;
};
Expand Down

0 comments on commit e168a10

Please sign in to comment.