A finite state machine library using ES6 promises