javascript-state-machine 状态模式之有限状态机 http://www.ruanyifeng.com/blog/2013/09/finite-state_machine_for_javascript.html