An AI for handling async callbacks in JavaScript