title: How to execute two asynchronous function in sequence
body: <p>How to make asynchronous Javascript function execute in sequence</p>
  
  <pre><code>socket_connection.on('request', function (obj) {
      process(obj);
  });
  function process(obj){
      readfile(function(content){ //async
          //read content
          //modify content
          writefile(content, function(){ //async
              //write content
          });
      });
  }
  </code></pre>
  
  <p>This results in sequence:</p>
  
  <pre><code>read content
  read content
  modify content
  modify content
  write content
  write content
  </code></pre>
  
  <p>How can I enforce:</p>
  
  <pre><code>read content
  modify content
  write content
  read content
  modify content
  write content
  </code></pre>