Comparing version 0.5.0 to 0.6.0
@@ -84,3 +84,3 @@ "use strict"; | ||
var DEF_OPS = { | ||
numeric: ["count", "sum", "avg", "stdev"], | ||
numeric: ["count", "sum", "max", "min", "avg", "stdev"], | ||
category: ["sum", "freq", "mode"] | ||
@@ -101,2 +101,4 @@ }; | ||
"sum": { fn: NOps.sum, deps: [] }, | ||
"max": { fn: NOps.max, deps: [] }, | ||
"min": { fn: NOps.min, deps: [] }, | ||
"avg": { fn: NOps.avg, deps: [] }, | ||
@@ -297,6 +299,6 @@ "stdev": { fn: NOps.stdev, deps: ["avg"] } | ||
vals = vals.map(function (v) { | ||
return { t: now, v: v, l: 1 }; | ||
return { t: now, v: v, l: 1, max: v, min: v }; | ||
}); | ||
if (!arr.length) arr.push({ t: now, v: 0, l: 0 }); | ||
if (!arr.length) arr.push({ t: now, v: 0, l: 0, max: -Infinity, min: Infinity }); | ||
var last = clone(arr[arr.length - 1]); | ||
@@ -307,2 +309,3 @@ | ||
last.v += v.v;last.l += 1; | ||
last.max = Math.max(last.max, v.v), last.min = Math.min(last.min, v.v); | ||
}); | ||
@@ -424,3 +427,3 @@ var oa = [arr.pop()], | ||
vals = vals.map(function (v) { | ||
return { v: v, l: 1 }; | ||
return { v: v, l: 1, max: v, min: v }; | ||
}); | ||
@@ -502,2 +505,16 @@ vals.forEach(function (v) { | ||
}, | ||
max: function max(currval, newitems, olditems, allitems, newstats, oldstats) { | ||
var max = -Infinity, | ||
len = allitems.length; | ||
for (var i = 0; i < len; i++) { | ||
max = Math.max(max, allitems[i].max); | ||
}return max; | ||
}, | ||
min: function min(currval, newitems, olditems, allitems, newstats, oldstats) { | ||
var min = Infinity, | ||
len = allitems.length; | ||
for (var i = 0; i < len; i++) { | ||
min = Math.min(min, allitems[i].min); | ||
}return min; | ||
}, | ||
avg: function avg(currval, newitems, olditems, allitems, newstats, oldstats) { | ||
@@ -504,0 +521,0 @@ var ln = OPS.count(0, 0, 0, newitems), |
/*! swstats 2017-06-08 */ | ||
"use strict";function _classCallCheck(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function t(t,s){for(var n=0;n<s.length;n++){var r=s[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(s,n,r){return n&&t(s.prototype,n),r&&t(s,r),s}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function t(s,n,r){function e(o,a){if(!n[o]){if(!s[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(i)return i(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var f=n[o]={exports:{}};s[o][0].call(f.exports,function(t){var n=s[o][1][t];return e(n||t)},f,f.exports,t,s,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)e(r[o]);return e}({1:[function(t,s,n){!function(s){var n=t("./main.js");s.SWindow=n}(window)},{"./main.js":3}],2:[function(t,s,n){s.exports={sum:function(t,s,n,r,e,i){t=void 0===t?{}:t;for(var o=s.length,a=n.length,u=0;u<o;u++)for(var h in s[u].v)t[h]=t[h]||0,t[h]+=s[u].v[h];for(var f=0;f<a;f++)for(var c in n[f].v)t[c]=t[c]||0,t[c]-=n[f].v[c];return t},freq:function(t,s,n,r,e,i){var o=e.sum,a=0,u={};for(var h in o)a+=o[h];for(var f in o)u[f]=o[f]/a;return u},mode:function(t,s,n,r,e,i){var o=e.sum,a=[];for(var u in o)a.push({k:u,t:o[u]});return a.sort(function(t,s){return t.t-s.t}),(a.pop()||{}).k}}},{}],3:[function(t,s,n){function r(t){if("object"!=(void 0===t?"undefined":_typeof(t)))return t;var s={};for(var n in t)s[n]=r(t[n]);return s}function e(t,s,n,r,e){p[t][s]={fn:r,deps:n},e&&c[t].push(s)}function i(t,s,n){var r=p[n][t].deps;return!!r.length&&(r.indexOf(s)>=0||r.reduce(function(t,r){return t||i(r,s,n)},!1))}function o(t,s){var n={},r=!1;t.forEach(function(t){return n[t]=!0});do{r=!1,t.forEach(function(e){p[s][e].deps.forEach(function(s){n[s]||(n[s]=!0,t.push(s),r=!0)})})}while(r);if(t.length>1){var e=null,o=!1;do{o=!1;for(var a=0;a<t.length;a++)for(var u=a;u<t.length;u++)i(t[a],t[u],s)&&(e=t[a],t[a]=t[u],t[u]=e,o=!0)}while(o)}}var a=t("./nops.js"),u=t("./cops.js"),h=[],f={numeric:"numeric",category:"category"},c={numeric:["count","sum","avg","stdev"],category:["sum","freq","mode"]},v={type:f.numeric,ops:c.numeric,step:1e3},p={numeric:{count:{fn:a.count,deps:[]},sum:{fn:a.sum,deps:[]},avg:{fn:a.avg,deps:[]},stdev:{fn:a.stdev,deps:["avg"]}},category:{sum:{fn:u.sum,deps:[]},freq:{fn:u.freq,deps:["sum"]},mode:{fn:u.mode,deps:["sum"]}}};setInterval(function(){var t=Date.now();h.filter(function(t){return!t._pause}).forEach(function(s){for(var n=s._arr,e=s._time,i=s._type,o=[],a=r(s.stats);n.length&&t-n[0].t>e;)o.push(n.shift());s._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],[],o,s._arr,s.stats,a)})})},1e3);var l=function(){function t(s,n){_classCallCheck(this,t),n=n||v,this._options=n,this._arr=[],this._time=s||1e4,this._type=n.type||v.type,this._ops=n.ops||c[this._type],this._step=n.step||v.step,this._pause=!1,this._active=!0,this._oldstats={},this.stats=r(n.stats||{}),o(this._ops,this._type),h.push(this)}return _createClass(t,[{key:"clean",value:function(){this._arr=[],this._oldstats={},this.stats=r(this._options.stats||{})}},{key:"push",value:function(t){if(this._active&&!this._pause)return t=t instanceof Array?t:[t],this._type==f.numeric?this._pushNum(t):this._pushCat(t)}},{key:"pause",value:function(){this._pause=!0}},{key:"resume",value:function(t){var s=this._arr;if(t&&s.length){var n=Date.now()-s[s.length].t;s.length.forEach(function(t){return t.t+=n})}this._pause=!1}},{key:"destroy",value:function(){var t=h.indexOf(this);h.splice(t,1),this._active=!1}},{key:"_pushNum",value:function(t){var s=this,n=Date.now(),e=this._arr,i=this._type,o=r(this.stats);t=t.map(function(t){return{t:n,v:t,l:1}}),e.length||e.push({t:n,v:0,l:0});var a=r(e[e.length-1]);if(n-a.t<this._step){t.forEach(function(t){a.v+=t.v,a.l+=1});var u=[e.pop()],h=[a];e.push(a),this._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],h,u,e,s.stats,o)})}else t.forEach(function(t){e.push(t)}),this._ops.forEach(function(n){s.stats[n]=p[i][n].fn(s.stats[n],t,[],e,s.stats,o)});return this}},{key:"_pushCat",value:function(t){var s=this,n=Date.now(),e=this._arr,i=this._type,o=r(this.stats),a={};t.forEach(function(t){a[t]=a[t]||0,a[t]++}),e.length||e.push({t:n,v:{}});var u=r(e[e.length-1]);if(n-u.t<this._step){for(var h in a)u.v[h]=u.v[h]||0,u.v[h]+=a[h];var f=[e.pop()],c=[u];e.push(u),this._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],c,f,e,s.stats,o)})}else{var v={t:n,v:a};e.push(v),this._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],[v],[],e,s.stats,o)})}return this}},{key:"length",get:function(){return this._arr.length}}]),t}(),_=function(){function t(s,n){_classCallCheck(this,t),n=n||v,this._options=n,this._arr=[],this._size=s||1e3,this._type=n.type||v.type,this._ops=n.ops||c[this._type],this.stats=r(n.stats||{}),o(this._ops,this._type)}return _createClass(t,[{key:"clean",value:function(){this._arr=[],this._oldstats={},this.stats=r(this._options.stats||{})}},{key:"push",value:function(t){return t=t instanceof Array?t:[t],this._type==f.numeric?this._pushNum(t):this._pushCat(t)}},{key:"_pushNum",value:function(t){var s=this,n=this._arr,e=[],i=this._type,o=r(this.stats);for((t=t.map(function(t){return{v:t,l:1}})).forEach(function(t){return s._arr.push(t)});this._arr.length>this._size;)e.push(this._arr.shift());return this._ops.forEach(function(r){s.stats[r]=p[i][r].fn(s.stats[r],t,e,n,s.stats,o)}),this}},{key:"_pushCat",value:function(t){var s=this,n=this._arr,e=[],i=this._type,o=r(this.stats),a={v:{}};for(t.forEach(function(t){a.v[t]=a.v[t]||0,a.v[t]++}),this._arr.push(a);this._arr.length>this._size;)e.push(this._arr.shift());return this._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],[a],e,n,s.stats,o)}),this}},{key:"length",get:function(){return this._arr.length}}]),t}();s.exports={TimeStats:l,SizeStats:_,register:e}},{"./cops.js":2,"./nops.js":4}],4:[function(t,s,n){var r={count:function(t,s,n,r,e,i){for(var o=0,a=r.length,u=0;u<a;u++)o+=r[u].l||1;return o},sum:function(t,s,n,r,e,i){t=void 0===t?0:t;for(var o=s.length,a=n.length,u=0;u<o;u++)t+=s[u].v;for(var h=0;h<a;h++)t-=n[h].v;return t},avg:function(t,s,n,e,i,o){var a=r.count(0,0,0,s),u=r.count(0,0,0,n),h=r.count(0,0,0,e),f=h-a+u;t=void 0===t?0:t,t*=f;for(var c=0;c<s.length;c++)t+=s[c].v;for(var v=0;v<n.length;v++)t-=n[v].v;return t/=h,isNaN(t)?0:t},stdev:function(t,s,n,e,i,o){o.stdev=o.stdev||{avg:1,sqsum:0,sum:0,stdev:0};for(var a=r.count(0,0,0,s),u=r.count(0,0,0,n),h=(r.count(0,0,0,e),e.length),f=(o.avg,o.stdev.avg,o.stdev.sqsum),c=o.stdev.sum,v=i.avg||0,p=f,l=c,_=0;_<n.length;_++){var y=n[_].v/(n[_].l||1);p-=y*y,l-=y}for(var m=0;m<s.length;m++){var g=s[m].v/(s[m].l||1);p+=g*g,l+=g}var d=Math.sqrt((p-2*v*l+h*v*v)/h);return{avg:v,sqsum:p,sum:l,stdev:d}}};s.exports=r},{}]},{},[1]); | ||
"use strict";function _classCallCheck(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function t(t,s){for(var n=0;n<s.length;n++){var r=s[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(s,n,r){return n&&t(s.prototype,n),r&&t(s,r),s}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function t(s,n,r){function e(a,o){if(!n[a]){if(!s[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(i)return i(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var f=n[a]={exports:{}};s[a][0].call(f.exports,function(t){var n=s[a][1][t];return e(n||t)},f,f.exports,t,s,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)e(r[a]);return e}({1:[function(t,s,n){!function(s){var n=t("./main.js");s.SWindow=n}(window)},{"./main.js":3}],2:[function(t,s,n){s.exports={sum:function(t,s,n,r,e,i){t=void 0===t?{}:t;for(var a=s.length,o=n.length,u=0;u<a;u++)for(var h in s[u].v)t[h]=t[h]||0,t[h]+=s[u].v[h];for(var f=0;f<o;f++)for(var c in n[f].v)t[c]=t[c]||0,t[c]-=n[f].v[c];return t},freq:function(t,s,n,r,e,i){var a=e.sum,o=0,u={};for(var h in a)o+=a[h];for(var f in a)u[f]=a[f]/o;return u},mode:function(t,s,n,r,e,i){var a=e.sum,o=[];for(var u in a)o.push({k:u,t:a[u]});return o.sort(function(t,s){return t.t-s.t}),(o.pop()||{}).k}}},{}],3:[function(t,s,n){function r(t){if("object"!=(void 0===t?"undefined":_typeof(t)))return t;var s={};for(var n in t)s[n]=r(t[n]);return s}function e(t,s,n,r,e){p[t][s]={fn:r,deps:n},e&&c[t].push(s)}function i(t,s,n){var r=p[n][t].deps;return!!r.length&&(r.indexOf(s)>=0||r.reduce(function(t,r){return t||i(r,s,n)},!1))}function a(t,s){var n={},r=!1;t.forEach(function(t){return n[t]=!0});do{r=!1,t.forEach(function(e){p[s][e].deps.forEach(function(s){n[s]||(n[s]=!0,t.push(s),r=!0)})})}while(r);if(t.length>1){var e=null,a=!1;do{a=!1;for(var o=0;o<t.length;o++)for(var u=o;u<t.length;u++)i(t[o],t[u],s)&&(e=t[o],t[o]=t[u],t[u]=e,a=!0)}while(a)}}var o=t("./nops.js"),u=t("./cops.js"),h=[],f={numeric:"numeric",category:"category"},c={numeric:["count","sum","max","min","avg","stdev"],category:["sum","freq","mode"]},v={type:f.numeric,ops:c.numeric,step:1e3},p={numeric:{count:{fn:o.count,deps:[]},sum:{fn:o.sum,deps:[]},max:{fn:o.max,deps:[]},min:{fn:o.min,deps:[]},avg:{fn:o.avg,deps:[]},stdev:{fn:o.stdev,deps:["avg"]}},category:{sum:{fn:u.sum,deps:[]},freq:{fn:u.freq,deps:["sum"]},mode:{fn:u.mode,deps:["sum"]}}};setInterval(function(){var t=Date.now();h.filter(function(t){return!t._pause}).forEach(function(s){for(var n=s._arr,e=s._time,i=s._type,a=[],o=r(s.stats);n.length&&t-n[0].t>e;)a.push(n.shift());s._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],[],a,s._arr,s.stats,o)})})},1e3);var l=function(){function t(s,n){_classCallCheck(this,t),n=n||v,this._options=n,this._arr=[],this._time=s||1e4,this._type=n.type||v.type,this._ops=n.ops||c[this._type],this._step=n.step||v.step,this._pause=!1,this._active=!0,this._oldstats={},this.stats=r(n.stats||{}),a(this._ops,this._type),h.push(this)}return _createClass(t,[{key:"clean",value:function(){this._arr=[],this._oldstats={},this.stats=r(this._options.stats||{})}},{key:"push",value:function(t){if(this._active&&!this._pause)return t=t instanceof Array?t:[t],this._type==f.numeric?this._pushNum(t):this._pushCat(t)}},{key:"pause",value:function(){this._pause=!0}},{key:"resume",value:function(t){var s=this._arr;if(t&&s.length){var n=Date.now()-s[s.length].t;s.length.forEach(function(t){return t.t+=n})}this._pause=!1}},{key:"destroy",value:function(){var t=h.indexOf(this);h.splice(t,1),this._active=!1}},{key:"_pushNum",value:function(t){var s=this,n=Date.now(),e=this._arr,i=this._type,a=r(this.stats);t=t.map(function(t){return{t:n,v:t,l:1,max:t,min:t}}),e.length||e.push({t:n,v:0,l:0,max:-1/0,min:1/0});var o=r(e[e.length-1]);if(n-o.t<this._step){t.forEach(function(t){o.v+=t.v,o.l+=1,o.max=Math.max(o.max,t.v),o.min=Math.min(o.min,t.v)});var u=[e.pop()],h=[o];e.push(o),this._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],h,u,e,s.stats,a)})}else t.forEach(function(t){e.push(t)}),this._ops.forEach(function(n){s.stats[n]=p[i][n].fn(s.stats[n],t,[],e,s.stats,a)});return this}},{key:"_pushCat",value:function(t){var s=this,n=Date.now(),e=this._arr,i=this._type,a=r(this.stats),o={};t.forEach(function(t){o[t]=o[t]||0,o[t]++}),e.length||e.push({t:n,v:{}});var u=r(e[e.length-1]);if(n-u.t<this._step){for(var h in o)u.v[h]=u.v[h]||0,u.v[h]+=o[h];var f=[e.pop()],c=[u];e.push(u),this._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],c,f,e,s.stats,a)})}else{var v={t:n,v:o};e.push(v),this._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],[v],[],e,s.stats,a)})}return this}},{key:"length",get:function(){return this._arr.length}}]),t}(),_=function(){function t(s,n){_classCallCheck(this,t),n=n||v,this._options=n,this._arr=[],this._size=s||1e3,this._type=n.type||v.type,this._ops=n.ops||c[this._type],this.stats=r(n.stats||{}),a(this._ops,this._type)}return _createClass(t,[{key:"clean",value:function(){this._arr=[],this._oldstats={},this.stats=r(this._options.stats||{})}},{key:"push",value:function(t){return t=t instanceof Array?t:[t],this._type==f.numeric?this._pushNum(t):this._pushCat(t)}},{key:"_pushNum",value:function(t){var s=this,n=this._arr,e=[],i=this._type,a=r(this.stats);for((t=t.map(function(t){return{v:t,l:1,max:t,min:t}})).forEach(function(t){return s._arr.push(t)});this._arr.length>this._size;)e.push(this._arr.shift());return this._ops.forEach(function(r){s.stats[r]=p[i][r].fn(s.stats[r],t,e,n,s.stats,a)}),this}},{key:"_pushCat",value:function(t){var s=this,n=this._arr,e=[],i=this._type,a=r(this.stats),o={v:{}};for(t.forEach(function(t){o.v[t]=o.v[t]||0,o.v[t]++}),this._arr.push(o);this._arr.length>this._size;)e.push(this._arr.shift());return this._ops.forEach(function(t){s.stats[t]=p[i][t].fn(s.stats[t],[o],e,n,s.stats,a)}),this}},{key:"length",get:function(){return this._arr.length}}]),t}();s.exports={TimeStats:l,SizeStats:_,register:e}},{"./cops.js":2,"./nops.js":4}],4:[function(t,s,n){var r={count:function(t,s,n,r,e,i){for(var a=0,o=r.length,u=0;u<o;u++)a+=r[u].l||1;return a},sum:function(t,s,n,r,e,i){t=void 0===t?0:t;for(var a=s.length,o=n.length,u=0;u<a;u++)t+=s[u].v;for(var h=0;h<o;h++)t-=n[h].v;return t},max:function(t,s,n,r,e,i){for(var a=-1/0,o=r.length,u=0;u<o;u++)a=Math.max(a,r[u].max);return a},min:function(t,s,n,r,e,i){for(var a=1/0,o=r.length,u=0;u<o;u++)a=Math.min(a,r[u].min);return a},avg:function(t,s,n,e,i,a){var o=r.count(0,0,0,s),u=r.count(0,0,0,n),h=r.count(0,0,0,e),f=h-o+u;t=void 0===t?0:t,t*=f;for(var c=0;c<s.length;c++)t+=s[c].v;for(var v=0;v<n.length;v++)t-=n[v].v;return t/=h,isNaN(t)?0:t},stdev:function(t,s,n,e,i,a){a.stdev=a.stdev||{avg:1,sqsum:0,sum:0,stdev:0};for(var o=r.count(0,0,0,s),u=r.count(0,0,0,n),h=(r.count(0,0,0,e),e.length),f=(a.avg,a.stdev.avg,a.stdev.sqsum),c=a.stdev.sum,v=i.avg||0,p=f,l=c,_=0;_<n.length;_++){var m=n[_].v/(n[_].l||1);p-=m*m,l-=m}for(var y=0;y<s.length;y++){var g=s[y].v/(s[y].l||1);p+=g*g,l+=g}var d=Math.sqrt((p-2*v*l+h*v*v)/h);return{avg:v,sqsum:p,sum:l,stdev:d}}};s.exports=r},{}]},{},[1]); |
16
main.js
@@ -15,3 +15,3 @@ const NOps = require("./nops.js"); | ||
const DEF_OPS = { | ||
numeric : ["count","sum","avg","stdev"], | ||
numeric : ["count","sum","max","min","avg","stdev"], | ||
category : ["sum","freq","mode"] | ||
@@ -32,2 +32,4 @@ }; | ||
"sum" : {fn:NOps.sum,deps:[]}, | ||
"max" : {fn:NOps.max,deps:[]}, | ||
"min" : {fn:NOps.min,deps:[]}, | ||
"avg" : {fn:NOps.avg,deps:[]}, | ||
@@ -213,9 +215,13 @@ "stdev" : {fn:NOps.stdev,deps:["avg"]}, | ||
vals = vals.map(v=>{return {t:now,v:v,l:1};}); | ||
vals = vals.map(v=>{return {t:now,v:v,l:1,max:v,min:v};}); | ||
if(!arr.length) arr.push({t:now,v:0,l:0}); | ||
if(!arr.length) arr.push({t:now,v:0,l:0,max:-Infinity,min:Infinity}); | ||
var last = clone(arr[arr.length-1]); | ||
if(now-last.t < this._step) { | ||
vals.forEach(v=>{last.v+=v.v; last.l+=1;}); | ||
vals.forEach(v=>{ | ||
last.v+=v.v; last.l+=1; | ||
last.max = Math.max(last.max,v.v), | ||
last.min = Math.min(last.min,v.v) | ||
}); | ||
var oa = [arr.pop()], na = [last]; | ||
@@ -317,3 +323,3 @@ arr.push(last); | ||
vals = vals.map(v=>{return {v:v,l:1};}); | ||
vals = vals.map(v=>{return {v:v,l:1,max:v,min:v};}); | ||
vals.forEach(v=>this._arr.push(v)); | ||
@@ -320,0 +326,0 @@ |
12
nops.js
@@ -15,2 +15,14 @@ const OPS = { | ||
}, | ||
max(currval,newitems,olditems,allitems,newstats,oldstats) { | ||
var max = -Infinity, len = allitems.length; | ||
for(let i=0;i<len;i++) | ||
max = Math.max(max,allitems[i].max); | ||
return max; | ||
}, | ||
min(currval,newitems,olditems,allitems,newstats,oldstats) { | ||
var min = Infinity, len = allitems.length; | ||
for(let i=0;i<len;i++) | ||
min = Math.min(min,allitems[i].min); | ||
return min; | ||
}, | ||
avg(currval,newitems,olditems,allitems,newstats,oldstats) { | ||
@@ -17,0 +29,0 @@ var |
{ | ||
"name": "swstats", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Sliding window statistics", | ||
@@ -5,0 +5,0 @@ "author": "David Gómez Matarrodona <solzimer@gmail.com>", |
@@ -14,3 +14,3 @@ # swstats | ||
* Core category stats: sum, frequency, mode | ||
* Core numeric stats: count, sum, avg, stdev | ||
* Core numeric stats: count, sum, min, max, avg, stdev | ||
* Plugable custom stats functions | ||
@@ -78,2 +78,4 @@ * Time windows are slided each second | ||
avg: 0.48705299187224704, | ||
max: 0.9865126881294235, | ||
min: 0.0023880687887007923, | ||
stdev: | ||
@@ -90,2 +92,4 @@ { avg: 0.48705299187224704, | ||
avg: 0.4980235682615189, | ||
max: 0.9865126881294235, | ||
min: 0.0023880687887007923, | ||
stdev: | ||
@@ -220,2 +224,4 @@ { avg: 0.4980235682615189, | ||
v : 12.34, // Total value for this slot | ||
min : 2.4 // Minimum of the accumulated values | ||
max : 4.5 // Maximum of the accumulated values | ||
l : 4 // Values accumulated in this slot | ||
@@ -222,0 +228,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82861
1106
303