Skip to content

Commit 5e63068

Browse files
author
Claire Nord
committed
warriors_game: eslint, incorporate decaffeinate suggestions, fix link
1 parent f7d97c1 commit 5e63068

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

disabled_scripts/warriors_game.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/*
2-
* decaffeinate suggestions:
3-
* DS102: Remove unnecessary code created because of implicit returns
4-
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
5-
*/
61
// Description:
72
// Warriors game score
83
//
@@ -11,35 +6,39 @@
116

127
const querystring = require('querystring');
138

14-
module.exports = function(robot) {
9+
let rangeFn;
1510

16-
const config = require('hubot-conf')('util', robot);
11+
module.exports = (robot) => {
12+
robot.respond(/clear$/, (res) => res.send((rangeFn(1, 60, true).map(() => '.')).join('\n')));
1713

18-
robot.respond(/clear$/, res => res.send((__range__(1, 60, true).map((n) => ".")).join("\n")));
19-
20-
if (robot.adapterName === "slack") {
21-
robot.logger.info("Adapter is slack: will terminate on client close");
22-
robot.adapter.client.on('close', () => process.exit(0));
23-
} else {
24-
robot.logger.info("Adapter is not slack, will not terminate on client close");
25-
}
14+
if (robot.adapterName === 'slack') {
15+
robot.logger.info('Adapter is slack: will terminate on client close');
16+
robot.adapter.client.on('close', () => process.exit(0));
17+
} else {
18+
robot.logger.info('Adapter is not slack, will not terminate on client close');
19+
}
2620

27-
return robot.respond(/warriors score/i, res => robot.http("http://espn.go.com/nba/bottomline/scores").get()(function(err, result, body) {
21+
robot.respond(/warriors score/i, (res) => robot.http('http://www.espn.com/nba/bottomline/scores').get()((err, result, body) => {
2822
if (err || (result.statusCode !== 200)) {
29-
res.send("Had trouble getting the score :(");
23+
res.send('Had trouble getting the score :(');
3024
return;
3125
}
3226
const qs = querystring.parse(body);
33-
return res.send(qs.nba_s_left1);
27+
res.send(qs.nba_s_left1);
3428
}));
3529
};
3630

37-
function __range__(left, right, inclusive) {
38-
let range = [];
39-
let ascending = left < right;
40-
let end = !inclusive ? right : ascending ? right + 1 : right - 1;
41-
for (let i = left; ascending ? i < end : i > end; ascending ? i++ : i--) {
31+
rangeFn = (left, right, inclusive) => {
32+
const range = [];
33+
const ascending = left < right;
34+
let end;
35+
if (!inclusive) {
36+
end = right;
37+
} else {
38+
end = ascending ? right + 1 : right - 1;
39+
}
40+
for (let i = left; ascending ? i < end : i > end; ascending ? i += 1 : i -= 1) {
4241
range.push(i);
4342
}
4443
return range;
45-
}
44+
};

0 commit comments

Comments
 (0)