Simple flow control of asynchronous tasks in JavaScript