export class Queue { private lastJob?: Promise; push(job: () => Promise): Promise { const work = async () => { if (this.lastJob) { await this.lastJob; } return job(); }; this.lastJob = work(); return this.lastJob; } }