* Add a task at the end of the queue. * @see https://www.npmjs.com/package/fastq * @param data * @returns Promise - A Promise that will be fulfilled (rejected) when the task is completed successfully (unsuccessfully). * This promise could be ignored as it will not lead to a
(data: T)
| 84 | * This promise could be ignored as it will not lead to a `unhandledRejection`. |
| 85 | */ |
| 86 | async push(data: T): Promise<Task<T, R>> { |
| 87 | const id = uniqueId(); |
| 88 | const task: Task<T, R> = { id, status: 'idle', error: undefined, count: 0, data, result: undefined }; |
| 89 | this.store.set(id, task); |
| 90 | return this.queue.push(id); |
| 91 | } |
| 92 | |
| 93 | // TODO: Support more function delegation to fastq. |
| 94 |