These codes confused me in BlackJack Demo

These codes confused me in BlackJack Demo
0.0 0

#1

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?