@ptolemy2002/js-math-utils 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22,6 +22,10 @@ function wrapNumber(value, min, max) {
|
|
|
22
22
|
}
|
|
23
23
|
// Normalize the value by shifting it relative to min
|
|
24
24
|
const normalizedValue = value - min;
|
|
25
|
+
if (rangeSize === 1) {
|
|
26
|
+
// Special case: range size of 1 means only two values (min and max)
|
|
27
|
+
return normalizedValue % 2 === 0 ? min : max;
|
|
28
|
+
}
|
|
25
29
|
// Calculate the wrapped position within the range
|
|
26
30
|
// Use modulo to find where the value falls in the repeating pattern
|
|
27
31
|
// The +1 is to ensure that the range is inclusive of both min and max
|
|
@@ -33,7 +37,7 @@ function wrapNumber(value, min, max) {
|
|
|
33
37
|
// If wrappedValue is 0 and the value approaches from the left,
|
|
34
38
|
// we need to return the max value so that we can remain
|
|
35
39
|
// inclusive of the max boundary
|
|
36
|
-
if (wrappedValue === 0 && value
|
|
40
|
+
if (wrappedValue === 0 && value < max) {
|
|
37
41
|
return max;
|
|
38
42
|
}
|
|
39
43
|
// Shift back to the original range and return
|