How to build a program that cannot do the wrong thing 3 points by Darmani·1564 days ago·geek.sg·Show in HN
I would use a state machine in this case. The best tool for doing this in JavaScript/TypeScript is XState. Highly recommend.