@monstermann/fn
Version:
A utility library for TypeScript.
24 lines • 506 B
TypeScript
//#region src/number/clamp.d.ts
/**
* `clamp(value, min, max)`
*
* Constrains `value` to be between `min` and `max` (inclusive).
*
* ```ts
* clamp(10, 0, 5); // 5
* clamp(-2, 0, 5); // 0
* clamp(3, 0, 5); // 3
* ```
*
* ```ts
* pipe(10, clamp(0, 5)); // 5
* pipe(-2, clamp(0, 5)); // 0
* pipe(3, clamp(0, 5)); // 3
* ```
*/
declare const clamp: {
(min: number, max: number): (value: number) => number;
(value: number, min: number, max: number): number;
};
//#endregion
export { clamp };