wip more stuff

This commit is contained in:
itsMapleLeaf
2022-10-02 17:57:49 -05:00
parent dc6239e598
commit b6f244aaa0
8 changed files with 315 additions and 117 deletions

View File

@@ -10,14 +10,14 @@ export class AsyncQueue {
private items: QueueItem[] = []
private running = false
add<T>(callback: AsyncCallback<T>): Promise<Awaited<T>> {
append<T>(callback: AsyncCallback<T>): Promise<Awaited<T>> {
return new Promise((resolve, reject) => {
this.items.push({ callback, resolve: resolve as any, reject })
void this.runQueue()
void this.run()
})
}
private async runQueue() {
private async run() {
if (this.running) return
this.running = true