Alternative ways of calling javascript code sequentially with delays in between
<p>I have this code originally in python.</p>

<pre><code>SendSerialPortCommand("XXX")
time.delay(0.5)
SendSerialPortCommand("YYY")
</code></pre>

<p>I converted this code to node.js but the code looks much uglier.</p>

<pre><code>SendSerialPortCommand("XXX");

setTimeout(function () {
    SendSerialPortCommand("YYY");
}, 500);
</code></pre>

<p>Imagine if my python code looks like this.</p>

<pre><code>SendSerialPortCommand("XXX")
time.delay(0.5)
SendSerialPortCommand("YYY")
time.delay(0.5)
SendSerialPortCommand("AAA")
time.delay(0.5)
SendSerialPortCommand("BBB")
</code></pre>

<p>The node.js code will look really ugly with <code>setTimeout()</code> inside <code>setTimeout()</code>. </p>

<p>How can the node.js code be improved in terms of readability? I don't care about violating asynchronous nature of javascript for this question. Important thing is readability.</p>