A finite state machine library using promises