UNPKG

@cran/lib.vue.ref

Version:

Vue Reactivity Extensions

27 lines (23 loc) 739 B
/* eslint-disable @typescript-eslint/unified-signatures */ import type { MaybeThunk } from "./MaybeThunk"; import type { Thunk } from "./Thunk"; /** * Warning! Using `unthunk` on a value which can * only ever be a thunk is not advised. * Instead use `thunk()`. * @since 0.0.1 * @category Utility * @deprecated */ export function unthunk<T> ( thunk: Thunk<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 */ export function unthunk<T> ( thunk: MaybeThunk<T> ): T; export function unthunk<T> ( thunk: MaybeThunk<T> ) { return thunk instanceof Function ? thunk() : thunk; }