UNPKG

@cran/lib.vue.ref

Version:

Vue Reactivity Extensions

18 lines (14 loc) 392 B
import { type MaybeWrapped, eagerComputed, unwrap } from "../utility"; /** * @since 0.0.1 * @category Math * @inheritdoc Math.round */ export function useRound ( x: MaybeWrapped<number>, precision: MaybeWrapped<number> = 0 ) { return eagerComputed(function compute ( ) { const modifier = 10 ** unwrap(precision); return Math.round(unwrap(x) * modifier) / modifier; }); }