No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

queue.js 639B

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Queue = void 0;
  4. const throttler_1 = require("./throttler");
  5. class Queue extends throttler_1.Throttler {
  6. constructor(options) {
  7. super(options);
  8. this.cursor = 0;
  9. this.name = this.name || "queue";
  10. }
  11. hasWaitingTask() {
  12. return this.cursor !== this.total;
  13. }
  14. nextWaitingTaskIndex() {
  15. if (this.cursor >= this.total) {
  16. throw new Error("There is no more task in queue");
  17. }
  18. this.cursor++;
  19. return this.cursor - 1;
  20. }
  21. }
  22. exports.Queue = Queue;
  23. exports.default = Queue;