A textual state machine in javascript with an integrated implementation of Promises/A