| 90 | |
| 91 | // eslint-disable-next-line @typescript-eslint/promise-function-async |
| 92 | putMany(tasks: Array<Task<T>>): Promise<T>[] { |
| 93 | if (this.freeSpace && tasks.length > this.freeSpace) { |
| 94 | throw new Error(`${this.name} Queue exceeds max size of ${this.capacity}`); |
| 95 | } |
| 96 | |
| 97 | if (this._abort) { |
| 98 | throw new Error(`${this.name} Queue has been aborted`); |
| 99 | } |
| 100 | |
| 101 | return tasks.map((task, index) => { |
| 102 | return new Promise((resolve, reject) => { |
| 103 | this.queue.put({task, resolve, reject, index: this.nextIndex++}); |
| 104 | if (tasks.length - 1 === index) { |
| 105 | void this.take(); |
| 106 | } |
| 107 | }); |
| 108 | }); |
| 109 | } |
| 110 | |
| 111 | private processOutOfOrderTasks() { |
| 112 | // If already processing, let the existing call handle it. |