title: How to make a promise from setTimeout
body: <p>This is not a realworld problem, I'm just trying to understand how promises are created.</p>
  
  <p>I need to understand how to make a promise for a function that returns nothing, like setTimeout.</p>
  
  <p>Suppose I have:</p>
  
  <pre><code>function async(callback){ 
      setTimeout(function(){
          callback();
      }, 5000);
  }
  
  async(function(){
      console.log('async called back');
  });
  </code></pre>
  
  <p>How do I create a promise that <code>async</code> can return after the <code>setTimeout</code> is ready to <code>callback()</code>?</p>
  
  <p>I supposed wrapping it would take me somewhere:</p>
  
  <pre><code>function setTimeoutReturnPromise(){
  
      function promise(){}
  
      promise.prototype.then = function() {
          console.log('timed out');
      };
  
      setTimeout(function(){
          return ???
      },2000);
  
  
      return promise;
  }
  </code></pre>
  
  <p>But I can't think beyond this.</p>