UNPKG

@cran/lib.vue.ref

Version:

Vue Reactivity Extensions

30 lines (25 loc) 763 B
/* eslint-disable @typescript-eslint/unified-signatures */ import type { MaybeRef } from "./MaybeRef"; import type { RefLike } from "./RefLike"; import { isRef } from "vue"; /** * Warning! Using `unref` on a value which can * only ever be a ref is not advised. * Instead use `ref.value`. * @since 0.0.1 * @category Utility * @deprecated */ export function unref<T> ( ref: RefLike<T> ): T; /** * Return the inner value if the argument is a ref, * otherwise return the argument itself. * Additionally allows this function to work with computeds. * @since 0.0.1 * @category Utility * @inheritdoc vue!unref */ export function unref<T> ( ref: MaybeRef<T> ): T; export function unref<T> ( ref: MaybeRef<T> ) { return isRef(ref) ? ref.value : ref; }