Skip to content

Commit

Permalink
feat(feature): add combine async function
Browse files Browse the repository at this point in the history
  • Loading branch information
NguyenHuuLich committed Dec 27, 2022
1 parent fc54154 commit f700ee4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $ yarn
## Usage

```javascript
import { createAsyncQueue } from "AsyncQueue";
import { createAsyncQueue } from "asyncqueue-custom";
const queueProcess = createAsyncQueue();

// Some async function
Expand Down
17 changes: 17 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { IAsyncQueue, DeferredPromise, Callback } from './model';

/**
* takes a single of promise. returns a promise for when asyncFunc are finished
* @param {Promise} asyncFunc
* @return {Promise} Promise to resolve when asyncFunc are finished
*/

export function createAsyncQueue<T = void>(opts = { parallelConcurrent: false }): IAsyncQueue<T> {
const { parallelConcurrent } = opts
let queue: Callback<T>[] = []
Expand Down Expand Up @@ -46,6 +52,17 @@ export function createAsyncQueue<T = void>(opts = { parallelConcurrent: false })
}
}

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

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

const start = async () => {}

}

0 comments on commit f700ee4

Please sign in to comment.