-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #10: Random delay #13
base: main
Are you sure you want to change the base?
Conversation
What do you think, if Delay would be an array? If there is 1 number in the array, the delay will be equal to this number. If there are two numbers in the array, the delay would get random number in between.
It’d make simulating a more real change rate easier, agreed. Thanks for making this work! |
if (this.running) { | ||
if (this.options.delay.length == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires us to always pass an array as the delay, even if it’s set to a fixed number. It’d be better if it accepts either a number or an array. In the latter case, it uses the first and second element as the lower and upper boundaries for the random delay. So the conditional here would work as a type check for number
and array
.
But again, please make these changes in the CoffeeScript and just check in the compiled JS version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I believe it'd be more straightforward this way.
@jkintscher glad it fits! Never tried CoffeeScript before. Re-writing this in CS would be a nice excuse to try it! :) |
…implemented in CoffeeScript and compiled JS).
@jkintscher I've added verification if Delay property is Array or Integer and refactored the code a bit. Please check both CS and JS files. |
What do you think, if Delay would be an array?
If there is 1 number in the array, the delay will be equal to this number.
If there are two numbers in the array, the delay would get random number in between.