A finite state machine written in CoffeeScript