From 8d7231d92f64f7f271ac653138e91d88c7cdf187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Moumn=C3=A9?= Date: Thu, 6 Oct 2016 21:45:04 +0200 Subject: [PATCH] making jshint happy --- hs.js | 2 ++ js/samples/langton-ant/langton-ant.js | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/hs.js b/hs.js index 0943971..232bdc1 100644 --- a/hs.js +++ b/hs.js @@ -2,8 +2,10 @@ item({desc: 'rx-training-games'}, function () { item({key: 'i', cmd: 'sudo npm install'}) item({key: 'd', desc: 'dev mode build & run', cmd: 'npm start'}) item({key: 'p', desc: 'prod mode build & run', cmd: 'npm run start:prod'}) + item({key: 'l', cmd: 'npm run lint'}) item({key: 'g', desc: 'generate gh-pages' + '\n ', cmd: script( 'set -eu', + 'npm run lint', 'git checkout gh-pages', 'git merge master -m "Merge branch \'master\' into gh-pages"', 'npm run build:prod', diff --git a/js/samples/langton-ant/langton-ant.js b/js/samples/langton-ant/langton-ant.js index 6fa37f0..49330fb 100644 --- a/js/samples/langton-ant/langton-ant.js +++ b/js/samples/langton-ant/langton-ant.js @@ -1,13 +1,13 @@ -var squareSize = 4, antPulse = 1 +var squareSize = 4, antPulse = 1; -api.initGrid({squareSize: squareSize}) +api.initGrid({squareSize: squareSize}); -var boardLayer = api.addLayer({color: '#337ab7'}), antLayer = api.addLayer({color: '#275b8c'}) +var boardLayer = api.addLayer({color: '#337ab7'}), antLayer = api.addLayer({color: '#275b8c'}); // place the ant in the middle of the board -antLayer.fill({x: api.gameSize / 2, y: api.gameSize / 2}) +antLayer.fill({x: api.gameSize / 2, y: api.gameSize / 2}); -var pulse = Rx.Observable.interval(antPulse).share() +var pulse = Rx.Observable.interval(antPulse).share(); // is the ant walking on an activated square? var probes = pulse.map(() => antLayer.getActiveSquares()[0]) @@ -16,10 +16,10 @@ var probes = pulse.map(() => antLayer.getActiveSquares()[0]) active: boardLayer.getActiveSquares() .find(boardSquare => boardSquare.x == antSquare.x && boardSquare.y == antSquare.y) }) - ).share() + ).share(); // http://javascript.about.com/od/problemsolving/a/modulobug.htm -var modulo = (n, m) => ((n % m) + m) % m +var modulo = (n, m) => ((n % m) + m) % m; // determine next direction var directions = probes.scan((acc, step) => modulo(acc + (step.active ? -1 : 1), 4), 0) @@ -27,13 +27,13 @@ var directions = probes.scan((acc, step) => modulo(acc + (step.active ? -1 : 1), [api.directions.Left, api.directions.Up, api.directions.Right, api.directions.Down][directionIndex]) .map(direction => direction(antLayer.getActiveSquares()[0])) - .share() + .share(); // update ant's position -directions.do(antLayer.fill).subscribe(() => antLayer.clear(antLayer.getActiveSquares()[0])) +directions.do(antLayer.fill).subscribe(() => antLayer.clear(antLayer.getActiveSquares()[0])); // switch color of square left behind -probes.subscribe(step => (step.active ? boardLayer.clear : boardLayer.fill)(step.coord)) +probes.subscribe(step => (step.active ? boardLayer.clear : boardLayer.fill)(step.coord)); // handle end of 'game' directions.where(api.isOffLimits).subscribe(api.gameOver);