Bez popisu
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.

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Stack = void 0;
  4. const throttler_1 = require("./throttler");
  5. class Stack extends throttler_1.Throttler {
  6. constructor(options) {
  7. super(options);
  8. this.lastTotal = 0;
  9. this.stack = [];
  10. this.name = this.name || "stack";
  11. }
  12. hasWaitingTask() {
  13. return this.lastTotal !== this.total || this.stack.length > 0;
  14. }
  15. nextWaitingTaskIndex() {
  16. while (this.lastTotal < this.total) {
  17. this.stack.push(this.lastTotal);
  18. this.lastTotal++;
  19. }
  20. const next = this.stack.pop();
  21. if (next === undefined) {
  22. throw new Error("There is no more task in stack");
  23. }
  24. return next;
  25. }
  26. }
  27. exports.Stack = Stack;
  28. exports.default = Stack;