summaryrefslogtreecommitdiff
path: root/modules/Util.js
blob: cbe466df6ce63e051f240e8df1948763b6d26df8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
function useAverage() {
	var avg = 0;
	let weight = 0;
	const append = value => {
		avg = (weight * avg) + value;
		weight += 1;
		avg = avg/weight;
	}

	return [() => avg, append];
}

export { useAverage };