( low: number, high: number, getCurrentValue: (i: number) => number, value: number, )
| 1074 | } |
| 1075 | |
| 1076 | const findNearestBinarySearch = ( |
| 1077 | low: number, |
| 1078 | high: number, |
| 1079 | getCurrentValue: (i: number) => number, |
| 1080 | value: number, |
| 1081 | ) => { |
| 1082 | while (low <= high) { |
| 1083 | const middle = ((low + high) / 2) | 0 |
| 1084 | const currentValue = getCurrentValue(middle) |
| 1085 | |
| 1086 | if (currentValue < value) { |
| 1087 | low = middle + 1 |
| 1088 | } else if (currentValue > value) { |
| 1089 | high = middle - 1 |
| 1090 | } else { |
| 1091 | return middle |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | if (low > 0) { |
| 1096 | return low - 1 |
| 1097 | } else { |
| 1098 | return 0 |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | function calculateRange({ |
| 1103 | measurements, |
no outgoing calls
no test coverage detected