Skip to contentOpen History to see the last commit
serialized-async-queue.ts
12 lines304 Bytes
1export class SerializedAsyncQueue { 2 private tail: Promise<void> = Promise.resolve(); 4 run<T>(operation: () => Promise<T>): Promise<T> { 5 const result = this.tail.then(operation, operation); 6 this.tail = result.then(