1 | View Code Duplication | "use strict"; |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
2 | Object.defineProperty(exports, "__esModule", { value: true }); |
||
3 | var utils_1 = require("./utils"); |
||
4 | var SummonerMastery = /** @class */ (function () { |
||
5 | function SummonerMastery(APIKEY, region, summonerId) { |
||
6 | this.summonerId = summonerId; |
||
7 | this.APIKEY = APIKEY; |
||
8 | this.region = region; |
||
9 | } |
||
10 | SummonerMastery.prototype.level = function (callback) { |
||
11 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/scores/by-summoner/" |
||
12 | + (this.summonerId + "?api_key=" + this.APIKEY); |
||
13 | utils_1.getJSON(url, function (res, err) { |
||
14 | if (err) { |
||
15 | callback(null, err); |
||
16 | } |
||
17 | else { |
||
18 | callback(res.data); |
||
19 | } |
||
20 | }); |
||
21 | }; |
||
22 | SummonerMastery.prototype.points = function (callback) { |
||
23 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
||
24 | + (this.summonerId + "?api_key=" + this.APIKEY); |
||
25 | utils_1.getJSON(url, function (res) { |
||
26 | var points = 0; |
||
27 | res.data.forEach(function (champion) { |
||
28 | points += champion.championPoints; |
||
29 | }); |
||
30 | callback(points); |
||
31 | }); |
||
32 | }; |
||
33 | SummonerMastery.prototype.top = function (amount, callback) { |
||
34 | if (amount === void 0) { amount = 0; } |
||
0 ignored issues
–
show
|
|||
35 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
||
36 | + (this.summonerId + "?api_key=" + this.APIKEY); |
||
37 | utils_1.getJSON(url, function (res) { |
||
38 | var slice = amount === 0 ? res.data.length : amount; |
||
39 | callback(res.data.slice(0, slice)); |
||
40 | }); |
||
41 | }; |
||
42 | SummonerMastery.prototype.champion = function (champion, callback) { |
||
43 | if (Array.isArray(champion)) { |
||
44 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
||
45 | + (this.summonerId + "?api_key=" + this.APIKEY); |
||
46 | var returner_1 = []; |
||
47 | utils_1.getJSON(url, function (res) { |
||
48 | res.data.forEach(function (element) { |
||
49 | if (champion.indexOf(element.championId) !== -1) { |
||
50 | returner_1.push(element); |
||
51 | } |
||
52 | }); |
||
53 | callback(returner_1); |
||
54 | }); |
||
55 | } |
||
56 | else { |
||
57 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
||
0 ignored issues
–
show
Comprehensibility
Naming
Best Practice
introduced
by
The variable
url already seems to be declared on line 44 . Consider using another variable name or omitting the var keyword.
This check looks for variables that are declared in multiple lines. There may be several reasons for this. In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs. If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared. ![]() |
|||
58 | + (this.summonerId + "/by-champion/" + champion + "?api_key=" + this.APIKEY); |
||
59 | utils_1.getJSON(url, function (res, err) { |
||
60 | if (err) { |
||
61 | callback(null, err); |
||
62 | } |
||
63 | else { |
||
64 | callback(res.data); |
||
65 | } |
||
66 | }); |
||
67 | } |
||
68 | }; |
||
69 | return SummonerMastery; |
||
70 | }()); |
||
71 | exports.SummonerMastery = SummonerMastery; |
||
72 | //# sourceMappingURL=mastery.js.map |