@cran/lib.vue.ref
Version:
Vue Reactivity Extensions
21 lines (20 loc) • 581 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useStatAvg = void 0;
const vue_1 = require("vue");
const utility_1 = require("../utility");
/**
* @since 0.0.1
* @category Statistics
*/
function useStatAvg(values) {
return (0, vue_1.computed)(function computedMathAvg() {
let result = 0;
let index = 0;
for (const value of (0, utility_1.unwrap)(values)) {
result = ((index * result) + (0, utility_1.unwrap)(value)) / ++index;
}
return result;
});
}
exports.useStatAvg = useStatAvg;