class s{constructor(s){this.queue=[],this.maxSize=s}async enqueue(s,t=!0){this.maxSize&&this.queue.length===this.maxSize&&this.queue.shift();const i=t&&0===this.queue.length;this.queue.push(s),i&&await this.runTask()}async runTask(){const s=this.queue[0];s&&(await s.run(),this.queue.shift(),this.queue.length>0&&await this.runTask())}}export{s as S}