Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- waitgroup
- =========
- Simple helper to run asynchronous functions and wait for them to finish before calling a callback function.
- Callback use the node.js format:
- ```js
- cb = function(err, result...){...}
- ```
- Example with dummy asynchronous functions:
- ```js
- waitgroup([function(cb){
- setTimeout(function(){
- cb(null,2);
- }, 2);
- }, function(cb){
- setTimeout(function(){
- cb(null,1);
- }, 1);
- }], function(err, results){
- console.log("Done",results);
- });
- ```
- waitgroup
- ---------
- > *void* = waitgroup( *array* **funcs**, *function* **done** )
- Wait for all functions sent in the **funcs** array to complete a call the **done** function.
- - *array* **funcs**:
- An array of asynchronous function. See below.
- - *function* **done**:
- Will be called when all **funcs** functions are done. Or when a **funcs** function produce an error.
- funcs
- -----
- > function(*func* **done**)
- The callback passed as argument to every **funcs** function when they are call by **workgroup()**.
- - *func* **done**:
- The callback to indiquate when a **funcs** function is finished, or produce an error.
- done
- ----
- > function(*?* **err**, *?* **result**)
- TODO: finish it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement