class t{constructor(t,e){if(this._onFlush=t,this._bucket=[],this._timeout=e.timeout,this._length=e.length,this._timeoutId=null,null==this._timeout&&null==this._length)throw new Error("Illegal argument: You must specify at least one flush condition");if(null!=this._timeout&&this._timeout<=0)throw new Error("Illegal argument: timeout condition must be greater than 0");if(null!=this._length&&this._length<=0)throw new Error("Illegal argument: length condition must be greater than 0");this._flusher=()=>{this.flush()}}add(t){null!=this._timeout&&null==this._timeoutId&&(this._timeoutId=setTimeout(this._flusher,this._timeout)),this._bucket.push(t),null!=this._length&&this._bucket.length===this._length&&this.flush()}flush(){const t=[...this._bucket];t.length>0&&(this.clear(),this._onFlush(t))}clear(){clearTimeout(this._timeoutId),this._timeoutId=null,this._bucket=[]}get length(){return this._bucket.length}}export{t as Buffer};
//# sourceMappingURL=buffer.js.map
