const Cycle = require("./cycle").Cycle; const logger = require("./logger"); class CycleBuffer { constructor(purgeTime, fixed=false) { this.time = purgeTime; this.buffer=[]; var th = this; this.onclear = function(sp) {}; if(fixed) { this.fixed=true; } else { this.inter = setInterval(function() { th.purge(); }, this.time); } } purge() { this.onclear(this); this.buffer.length=0; } add(cycle) { this.buffer.push(cycle); if(this.fixed && this.buffer.length>=this.time) this.buffer.shift(); } all() { var ret=[]; for(var i=0;i