Add clamp function#545
Conversation
|
This would also need a readme update. Thanks for the work. |
|
Done |
|
Thanks for the quick response 👍 So reading your implementations of clamp i would prefer the parameter ordering of: value, min, max I think the function should be limited to 3 values, and not allowing arrays. |
|
Actually the order of params doesn't matter, it could be [max, min, value] or [max, value, min] or ... whatever. |
|
In other words you might have $range = [minLimit, maxLimit] and valueX. |
|
Bump |
There was a problem hiding this comment.
couldn't this just be args = args.flatten ?
|
Hi Michael, I added a few comments on issues with the code. I think the overall idea of the clamp function is great, but the code does need a bit work. Especially with the move of puppet 4 to more conscious and strict typing, please reconsider your plan to allow arbitrary arrays and strings as arguments. I would much prefer a more strict signature like tp suggested, that does just take three ints. |
Clamp keeps value within the range. Employ of soft() makes the whole thing is independant of order.
|
Hi David, thank you for the feedback. I've fixed issues w/ the code. |
|
Thanks for your work, @mpolenchuk ! |
Clamp keeps value within the range.
Employ of soft() makes the whole thing is independant of order.