Fix "coerceIn" for calls with max < min

Previously the min value was ignored in case the max value was less than the min value.
E.g. coerceIn(5, 0, -1) would be -1 instead of 0
This commit is contained in:
schroda
2025-02-12 19:53:05 +01:00
parent c6fe715e57
commit ffd6c5867f

View File

@@ -38,6 +38,6 @@ export const getValueFromObject = <T>(obj: Record<string, any>, key: string): T
return keys.reduce((acc, curr) => acc?.[curr], obj) as T;
};
export const coerceIn = (value: number, min: number, max: number): number => Math.min(Math.max(value, min), max);
export const coerceIn = (value: number, min: number, max: number): number => Math.max(Math.min(value, max), min);
export const noOp = () => {};