UNPKG

@cran/lib.vue.ref

Version:

Vue Reactivity Extensions

17 lines (14 loc) 360 B
import { type MaybeWrapped, eagerComputed, unwrap } from "../utility"; /** * @since 0.0.1 * @category Math */ export function useClamp ( value: MaybeWrapped<number>, min: MaybeWrapped<number>, max: MaybeWrapped<number> ) { return eagerComputed(function compute ( ) { return Math.min(unwrap(max), Math.max(unwrap(min), unwrap(value))); }); }