title: How to call clearTimeout and still run the setTimeout's function?
body: <p>Here is my code:</p>
  <pre><code>let delayTimeout = null;
  const delayExecution = mls =&gt; {
      console.log('Delaying for', mls);
      return new Promise(resolve =&gt; {
          delayTimeout = setTimeout(() =&gt; resolve('ok'), mls);
      })
  }
  
  const main = async () =&gt; {
      axios.post('URL', {data})
               .then(response =&gt; {
                   if(response passes some condition){
                       clearTimeout(delayTimeout);
                   }
               })
  
     const res = await delayExecution(30000)
     console.log(&quot;DONE!&quot;)
  }
  
  main();
  </code></pre>
  <p>After the axios call, I may want to terminate the <code>delayExecution</code> by clearing the timeout inside it. How do I clearTimeout inside my <code>delayExecution</code> function but still resolve the Promise?</p>
  <p>In essence, I'm trying to finish <code>delayExecution</code> before its time, but still resolve the promise inside it.</p>