Skip to content

Commit f700ee4

Browse files
author
NguyenHuuLich
committed
feat(feature): add combine async function
1 parent fc54154 commit f700ee4

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $ yarn
3434
## Usage
3535

3636
```javascript
37-
import { createAsyncQueue } from "AsyncQueue";
37+
import { createAsyncQueue } from "asyncqueue-custom";
3838
const queueProcess = createAsyncQueue();
3939

4040
// Some async function

src/main.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { IAsyncQueue, DeferredPromise, Callback } from './model';
22

3+
/**
4+
* takes a single of promise. returns a promise for when asyncFunc are finished
5+
* @param {Promise} asyncFunc
6+
* @return {Promise} Promise to resolve when asyncFunc are finished
7+
*/
8+
39
export function createAsyncQueue<T = void>(opts = { parallelConcurrent: false }): IAsyncQueue<T> {
410
const { parallelConcurrent } = opts
511
let queue: Callback<T>[] = []
@@ -46,6 +52,17 @@ export function createAsyncQueue<T = void>(opts = { parallelConcurrent: false })
4652
}
4753
}
4854

55+
/**
56+
* takes a custom parallel async function of promises. returns a promise for when all func of parallel async are finished
57+
* @param {Array} asyncFuncArray
58+
* @param {number} should parallel async run at 1 time. Default 2 async function run at the time
59+
* @return {Promise} Promise to resolve when parallel async (number config) are finished
60+
*/
61+
export function createAsyncCombineQueue<T = void>(asyncFuncArray: T[] = [], parallelLimit: number = 2 ): any {
4962

63+
const push = (task: Callback<T>) => {}
5064

65+
const start = async () => {}
66+
67+
}
5168

0 commit comments

Comments
 (0)