These codes confused me in BlackJack Demo

game-fsm.js

function on (message) {
   return function (msgToEvaluate) {
       return msgToEvaluate === message;
   };
}

playersTurn.to(dealersTurn).when(on("player acted"));

‘when’ function defined in StageJS
Transition.prototype.when = function (guard) {
this.guard = guard;
return this;
};

Who can tell me how these codes work?