Javascript and AngularJS implementation of tic tac toe, using design-by-contract and functional patterns