阮一峰博客
http://www.ruanyifeng.com/blog/2013/09/finite-state_machine_for_javascript.html
开源实现库(javascript-state-machine):
https://github.com/jakesgordon/javascript-state-machine