UNPKG

@cran/lib.vue.ref

Version:

Vue Reactivity Extensions

18 lines (15 loc) 421 B
import { computed } from "vue"; import { type MaybeWrapped, unwrap } from "../utility"; /** * @since 0.0.1 * @category Array * @inheritdoc Array#flat */ export function useFlat<T, Depth extends number = 20> ( values: MaybeWrapped<Array<MaybeWrapped<T>>>, depth: MaybeWrapped<Depth> = 20 as Depth ) { return computed(function compute ( ) { return unwrap(values).map<T>(unwrap).flat(unwrap(depth)); }); }