File "clamp.ts"

Full path: /home/fsibplc/public_html/sommilito-bank2/splide-4.1.3/src/js/utils/math/clamp/clamp.ts
File size: 417 B (417 B bytes)
MIME-type: text/x-java
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

import { max, min } from '../math/math';


/**
 * Clamps a number.
 *
 * @param number - A subject number to check.
 * @param x      - A min or max number.
 * @param y      - A min or max number.
 *
 * @return A clamped number.
 */
export function clamp( number: number, x: number, y: number ): number {
  const minimum = min( x, y );
  const maximum = max( x, y );
  return min( max( minimum, number ), maximum );
}