aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/lib/withinRange.js
blob: d3d4f24290e946f06f9ba9013454acc4b383ca4a (plain)
1
2
3
4
5
6
7
8
9
10
11
export default function withinRange(number, rangeMax) {
  if (number < 0) {
    return withinRange(number + (rangeMax + 1), rangeMax);
  }

  if (number > rangeMax) {
    return withinRange(number - (rangeMax + 1), rangeMax);
  }

  return number;
}