js ex machina - finite state machines in JavaScript