From 181d5726d7078150c34659feac30e30b72807674 Mon Sep 17 00:00:00 2001 From: Oleg Mokhov Date: Sun, 21 Jun 2015 20:14:38 +0300 Subject: [PATCH] limit speedsStoring to 10 measurings --- client/core/chitalka/chitalka.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/core/chitalka/chitalka.js b/client/core/chitalka/chitalka.js index b5f08b3..3e718b0 100644 --- a/client/core/chitalka/chitalka.js +++ b/client/core/chitalka/chitalka.js @@ -236,6 +236,11 @@ modules.define( _storeSpeed: function (speed) { this._speedAccumulator = this._speedAccumulator || []; + if (this._speedAccumulator.length > 9) { + do { + this._speedAccumulator.shift(); + } while (this._speedAccumulator.length !== 9); + } this._speedAccumulator.push(speed); this._speedAccumulator = this._speedAccumulator.sort(numSort);