title: Skip the function if executing time too long. JavaScript
body: <p>How can I skip a function if the executing time too long. </p>
  
  <p>For example I have 3 functions :</p>
  
  <pre><code>function A(){
   Do something.. ..
  }
  
  function B(){
   Do something.. ..
  }
  
  function C(){
   Do something.. ..
  }
  
  A();
  B();
  C();
  </code></pre>
  
  <p>So for example for some reason function B have infinity loop inside, and keep running. How can I skip function B and go to function C if function B executing too long ?</p>
  
  <p>I tried this but seem not working : </p>
  
  <pre><code>try {
   const setTimer = setTimeOut({ 
    throw new Error("Time out!");
   },500);
   B();
   clearInterval(setTimer);
  }
  catch(error){
   console.warn(error);
  }
  </code></pre>
  
  <p>But seem not working.</p>
  
  <hr>
  
  <p>Update 1 : FYI, I didn't do any anti-pattern but function B is something in NPM and I submitted issues to the owner of repo. Just try to dodge the bullet so I have some extra times until the fix. Thanks guys for helping me so far :)</p>