Executes promises sequentially, one at a time.
import {PromiseQueue} from "./PromiseQueue.js"
const queue = new PromiseQueue()
queue.enqueue(() => fetch("/api/first"))
queue.enqueue(() => fetch("/api/second")) // waits for first to complete
queue.enqueue(() => fetch("/api/third")) // waits for second to completeEach item must be a function that returns a promise. enqueue() itself returns a promise that resolves with the result of the enqueued function.
enqueue(promiseFunction)— add a promise-returning function to the queue. Returns aPromisethat resolves when the function completesdestroy()— stop processing and clear the queue