A micro Finite State Machine implementation in JavaScript