• Clamp a Number

    Parameters

    • input: number
    • min: number
    • max: number

    Returns number

    Example

    import { number } from "@rjweb/utils"

    number.clamp(100, 40, 200) // 100
    number.clamp(100, 2000, 200) // 200
    number.clamp(1042, 1000, 2000) // 1042

    Since

    1.12.10

    Supports

    nodejs, browser