Skip to content

Send files directly between devices over the internet - no cloud storage, no size limits.

366 B
Raw Blame
export class SerialQueue {
  private tail: Promise<unknown> = Promise.resolve(null)

  constructor(private readonly onError: (err: unknown) => void) {}

  run<T>(task: () => Promise<T>): Promise<T> {
    const result = this.tail.then(task)
    this.tail = result.catch(this.onError)
    return result
  }

  whenIdle(): Promise<unknown> {
    return this.tail
  }
}