async-fifo-queue.d.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * (c) 2017-2025 BullForce Labs AB, MIT Licensed.
  3. * @see LICENSE.md
  4. *
  5. */
  6. /**
  7. * AsyncFifoQueue
  8. *
  9. * A minimal FIFO queue for asynchronous operations. Allows adding asynchronous operations
  10. * and consume them in the order they are resolved.
  11. */
  12. export declare class AsyncFifoQueue<T> {
  13. private ignoreErrors;
  14. /**
  15. * A queue of completed promises. As the pending
  16. * promises are resolved, they are added to this queue.
  17. */
  18. private queue;
  19. /**
  20. * A set of pending promises.
  21. */
  22. private pending;
  23. /**
  24. * The next promise to be resolved. As soon as a pending promise
  25. * is resolved, this promise is resolved with the result of the
  26. * pending promise.
  27. */
  28. private nextPromise;
  29. private resolve;
  30. private reject;
  31. constructor(ignoreErrors?: boolean);
  32. add(promise: Promise<T>): void;
  33. waitAll(): Promise<void>;
  34. numTotal(): number;
  35. numPending(): number;
  36. numQueued(): number;
  37. private resolvePromise;
  38. private rejectPromise;
  39. private newPromise;
  40. private wait;
  41. fetch(): Promise<T | void>;
  42. }