UNPKG

@cran/lib.vue.ref

Version:

Vue Reactivity Extensions

15 lines (14 loc) 399 B
import { computed } from "vue"; import { wrapArrayReducer } from "./ArrayReducer"; import { unwrap } from "../utility"; /** * @since 0.0.1 * @category Array * @inheritdoc Array#reduce */ export function useReduce(values, callbackfn, initialValue) { return computed(function compute() { return unwrap(values) .reduce(wrapArrayReducer(callbackfn), initialValue); }); }