Advertisement
DigitalMag

JS async problem

Feb 16th, 2020
980
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const child_process = require("child_process");
  2.  
  3. async function Func(i){
  4.  
  5.     var r = '';
  6.     var summ = 1;
  7.     for(var i=0;i<10000000;i++) summ+=i;
  8.    
  9.     await console.log('Func ' + i + ': ' + r);
  10.    
  11.     return r;
  12. };
  13.  
  14. function Broker(i){
  15.     Func(i).then(function(){
  16.         console.log('Broker')
  17.     });
  18.    
  19.     return true;
  20. }
  21.  
  22. async function Start(){
  23.     var i = 0;
  24.     do{
  25.        
  26.         await Broker(i)
  27.        
  28.         console.log('outside: ' + i++);
  29.         if (i>5) break;
  30.     }while(true)
  31. }
  32.  
  33. Start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement