# clamp **Repository Path**: ArkTSCentralRepository/clamp ## Basic Information - **Project Name**: clamp - **Description**: Clamp a value between two other values - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-26 - **Last Updated**: 2026-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # clamp 基于[clamp](https://www.npmjs.com/package/clamp)原库1.0.1版本进行适配 Clamp a value between two other values. It's as simple as modules come - saving keystrokes because I've had to write this function too many times. ## Install ```sh ohpm install clamp ``` ## Usage ## ### `clamp(value, a, b)` ### Returns `value`, if it is between `a` and `b`. Otherwise, returns the number it's gone past. ```typescript import clamp from 'clamp'; expect(clamp(0, -100, 100)).assertEqual(0); expect(clamp(0, 100, 100)).assertEqual(100); expect(clamp(0, 100, -100)).assertEqual(0); expect(clamp(100, 0, 50)).assertEqual(50); expect(clamp(50, 100, 150)).assertEqual(100); ```