d7002057d7
This PR moves the tldraw.com app into the public repo. ### Change Type - [x] `internal` — Any other changes that don't affect the published package[^2] --------- Co-authored-by: Dan Groshev <git@dgroshev.com> Co-authored-by: alex <alex@dytry.ch>
15 lines
303 B
TypeScript
15 lines
303 B
TypeScript
export class Queue {
|
|
currentTask = Promise.resolve()
|
|
|
|
enqueue<T>(task: () => Promise<T>): Promise<T> {
|
|
return new Promise((resolve, reject) => {
|
|
this.currentTask = this.currentTask.then(async () => {
|
|
try {
|
|
resolve(await task())
|
|
} catch (err) {
|
|
reject(err)
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|