File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import { AsyncQueue } from "@axetroy/async-queue";
2929
3030const delay = (ms ) => new Promise ((resolve ) => setTimeout (resolve, ms));
3131
32- const queue = new AsyncTaskQueue (2 );
32+ const queue = new AsyncTaskQueue ({ concurrency : 2 } );
3333// Add task to the queue
3434queue .enqueue (() => delay (1000 ).then (() => console .log (" Task 1 completed" )));
3535queue .enqueue (() => delay (500 ).then (() => console .log (" Task 2 completed" )));
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ interface Task {
88type Promisify < T > = T extends Promise < any > ? T : Promise < T > ;
99
1010export interface AsyncQueueOptions {
11+ /**
12+ * The maximum number of concurrent tasks to run.
13+ * @default 1
14+ */
1115 concurrency ?: number ;
1216}
1317
You can’t perform that action at this time.
0 commit comments