summaryrefslogtreecommitdiff
path: root/src/modules/Util.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/Util.js')
-rw-r--r--src/modules/Util.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/modules/Util.js b/src/modules/Util.js
new file mode 100644
index 0000000..cbe466d
--- /dev/null
+++ b/src/modules/Util.js
@@ -0,0 +1,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 };