(value: number, [min, max]: [number, number], tolerance = 0)
| 1125 | const hash = season.split("").reduce((sum, char) => sum + char.charCodeAt(0), 0); |
| 1126 | return `hsl(${hash % 360}, 55%, 50%)`; |
| 1127 | } |
| 1128 | |
| 1129 | function rangeScore(value: number, [min, max]: [number, number], tolerance = 0) { |
| 1130 | if (value >= min && value <= max) return 1; |
| 1131 | if (value < min) { |
| 1132 | const gap = min - value; |
| 1133 | return clamp(1 - gap / Math.max(1, tolerance || min), 0, 1); |
| 1134 | } |
| 1135 | const gap = value - max; |
| 1136 | return clamp(1 - gap / Math.max(1, tolerance || max), 0, 1); |
| 1137 | } |
| 1138 |
no test coverage detected