@cran/lib.vue.ref
Version:
Vue Reactivity Extensions
17 lines (16 loc) • 406 B
JavaScript
import { computed } from "vue";
import { unwrap } from "../utility";
/**
* @since 0.0.1
* @category Statistics
*/
export function useStatAvg(values) {
return computed(function computedMathAvg() {
let result = 0;
let index = 0;
for (const value of unwrap(values)) {
result = ((index * result) + unwrap(value)) / ++index;
}
return result;
});
}