From 3bc2838360627f78a91a7cad81f3bc97711410c2 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 29 May 2022 14:50:55 -0500 Subject: refactor: move everything into src/ subdirectory --- src/modules/Util.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/modules/Util.js (limited to 'src/modules/Util.js') 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 }; -- cgit v1.2.1