UNPKG

@carbon/ibm-products

Version:
23 lines (21 loc) 651 B
/** * Copyright IBM Corp. 2020, 2026 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ //#region src/global/js/utils/clamp.ts /** * Copyright IBM Corp. 2025, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ const clamp = (value, min, max) => { if (isNaN(value) || isNaN(min) || isNaN(max)) return; if (max !== void 0) value = value <= max ? value : max; if (min !== void 0) value = value >= min ? value : min; return value; }; //#endregion exports.clamp = clamp;