@cran/lib.vue.ref
Version:
Vue Reactivity Extensions
17 lines (13 loc) • 345 B
text/typescript
import { type MaybeWrapped, eagerComputed, unwrap } from "../utility";
/**
* @since 0.2.3
* @category Object
*/
export function useArray<T> (
value: MaybeWrapped<Array<T> | T>
) {
return eagerComputed(function compute ( ) {
const unwrapped = unwrap(value);
return Array.isArray(unwrapped) ? unwrapped : [ unwrapped, ];
});
}