Guest User

Untitled

a guest
Nov 17th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. var App = function(start, cb) {
  2. var pendingRecursive = 0;
  3. var eventEmitter = new EventEmitter();
  4. cb(eventEmitter);
  5.  
  6. var Recursive = function(a) {
  7. // breadth-first search recursion
  8.  
  9. // before each recursive call:
  10. pendingRecursive++;
  11. Recursive(/*whatever*/);
  12.  
  13. // at the end of the function
  14. if (--activeRecursive == 0){
  15. eventEmitter.emit('end');
  16. }
  17. }
  18.  
  19. pendingRecursive = 1;
  20. Rec
Add Comment
Please, Sign In to add comment