Enforce FIFO ordering on async callbacks in Javascript