UNPKG

tstabilizer

Version:

stabilize fassi values, from sensors or logs

2 lines 734 B
var tStabilizer = function(t) { this.length = t || 1 / 0, this.values = [], this.push = function(t) { this.values.push(t), this.values.length - this.length > 0 && (this.values = this.values.slice(this.values.length - this.length)) }, this.getAvarage = function() { return this.getSum() / this.values.length }, this.getMax = function() { for (var t = -1 / 0, e = this.values.length; e--;) t = t < this.values[e] ? this.values[e] : t; return t }, this.getMin = function() { for (var t = 1 / 0, e = this.values.length; e--;) t = t > this.values[e] ? this.values[e] : t; return t }, this.getSum = function() { return this.values.reduce(function(t, e) { return t + e }, 0) } }; "object" != typeof window && (module.exports = tStabilizer);