MCPcopy Create free account
hub / github.com/Thanas-R/Virdis / rangeScore

Function rangeScore

src/components/CropPlanningSection.tsx:1127–1135  ·  view source on GitHub ↗
(value: number, [min, max]: [number, number], tolerance = 0)

Source from the content-addressed store, hash-verified

1125 const hash = season.split("").reduce((sum, char) => sum + char.charCodeAt(0), 0);
1126 return `hsl(${hash % 360}, 55%, 50%)`;
1127}
1128
1129function 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

Callers 1

scoreCropProfileFunction · 0.85

Calls 1

clampFunction · 0.85

Tested by

no test coverage detected