You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
329 B

2 months ago
  1. // @flow
  2. import { max as mathMax, min as mathMin } from './math';
  3. export function within(min: number, value: number, max: number): number {
  4. return mathMax(min, mathMin(value, max));
  5. }
  6. export function withinMaxClamp(min: number, value: number, max: number) {
  7. const v = within(min, value, max);
  8. return v > max ? max : v;
  9. }