react-native-awesome-slider
Version:
A versatile, responsive <Slider /> component for React Native and Web.
17 lines (16 loc) • 344 B
text/typescript
/**
* @summary Clamps a node with a lower and upper bound.
* @example
clamp(-1, 0, 100); // 0
clamp(1, 0, 100); // 1
clamp(101, 0, 100); // 100
* @worklet
*/
export const clamp = (
value: number,
lowerBound: number,
upperBound: number
) => {
'worklet';
return Math.min(Math.max(lowerBound, value), upperBound);
};