import { clampToUtilityNumber } from "./clamp" ; import { UtilityNumberValue , UtilityInput , ScoringDirection } from "./types" ; param min param max param input returns const getPositionInRange = ( min , max , input ) => { const adjustedMax = max - min ; const adjustedInput = input - min ; return adjustedInput / adjustedMax ; } ; param { UtilityInput } input returns export const getRangeValue = ( { value , range : [ min , max ] , direction } ) : UtilityNumberValue => { const inputValuePosition = getPositionInRange ( min , max , value ) ; const inputOutput = direction === ScoringDirection . High ? inputValuePosition * 200 : 200 - ( inputValuePosition * 200 ) ; return clampToUtilityNumber ( Math . floor ( inputOutput ) ) ; } ;