an attempt at a minimal finite state machine in es5 with the node.js api.