| 435 | return this.#status |
| 436 | } |
| 437 | _setStatus(status) { |
| 438 | if (status === this.#status) { |
| 439 | return |
| 440 | } |
| 441 | const currentIdx = TASK_STATUS_ORDER.indexOf(this.#status) |
| 442 | if (currentIdx < 0) { |
| 443 | throw Error(`The task status ${this.#status} is final and can't be changed.`) |
| 444 | } |
| 445 | const newIdx = TASK_STATUS_ORDER.indexOf(status) |
| 446 | if (newIdx >= 0 && newIdx < currentIdx) { |
| 447 | throw Error(`The task status ${status} can't replace ${this.#status}.`) |
| 448 | } |
| 449 | this.#status = status |
| 450 | } |
| 451 | |
| 452 | /** Send current task to server. |
| 453 | * @param {*} [timeout=-1] Optional timeout value in ms |