UNPKG

@azizbecha/strkit

Version:

strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.

28 lines 944 B
(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = clamp; /** * Clamps a number between a minimum and maximum value. * @param value - The number to clamp. * @param min - The minimum allowed value. * @param max - The maximum allowed value. * @returns The clamped value. * @example * clamp(15, 0, 10); // 10 * clamp(-5, 0, 10); // 0 * clamp(5, 0, 10); // 5 */ function clamp(value, min, max) { return Math.max(min, Math.min(max, value)); } }); //# sourceMappingURL=clamp.js.map