Advertisement
Guest User

Untitled

a guest
May 30th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. waitgroup
  2. =========
  3.  
  4. Simple helper to run asynchronous functions and wait for them to finish before calling a callback function.
  5.  
  6. Callback use the node.js format:
  7. ```js
  8. cb = function(err, result...){...}
  9. ```
  10.  
  11. Example with dummy asynchronous functions:
  12. ```js
  13. waitgroup([function(cb){
  14.  
  15. setTimeout(function(){
  16. cb(null,2);
  17. }, 2);
  18.  
  19. }, function(cb){
  20.  
  21. setTimeout(function(){
  22. cb(null,1);
  23. }, 1);
  24.  
  25. }], function(err, results){
  26. console.log("Done",results);
  27. });
  28. ```
  29.  
  30. waitgroup
  31. ---------
  32.  
  33. > *void* = waitgroup( *array* **funcs**, *function* **done** )
  34.  
  35. Wait for all functions sent in the **funcs** array to complete a call the **done** function.
  36.  
  37. - *array* **funcs**:
  38.  
  39. An array of asynchronous function. See below.
  40.  
  41. - *function* **done**:
  42.  
  43. Will be called when all **funcs** functions are done. Or when a **funcs** function produce an error.
  44.  
  45. funcs
  46. -----
  47.  
  48. > function(*func* **done**)
  49.  
  50. The callback passed as argument to every **funcs** function when they are call by **workgroup()**.
  51.  
  52. - *func* **done**:
  53.  
  54. The callback to indiquate when a **funcs** function is finished, or produce an error.
  55.  
  56. done
  57. ----
  58.  
  59. > function(*?* **err**, *?* **result**)
  60.  
  61. TODO: finish it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement