osrs-json-hiscores 2.15.0 → 2.16.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -4
- package/lib/hiscores.d.ts +17 -1
- package/lib/hiscores.js +109 -16
- package/lib/types.d.ts +34 -0
- package/lib/utils/constants.d.ts +5 -3
- package/lib/utils/constants.js +7 -5
- package/lib/utils/helpers.d.ts +2 -1
- package/lib/utils/helpers.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -110,10 +110,10 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
110
110
|
| Bounty Hunter (Legacy - Hunter) | `hunterBH` |
|
111
111
|
| Bounty Hunter (Rogue) | `rogueBHV2` |
|
112
112
|
| Bounty Hunter (Hunter) | `hunterBHV2` |
|
113
|
-
|
|
114
|
-
| PvP Arena
|
113
|
+
| LMS - Rank | `lastManStanding` |
|
114
|
+
| PvP Arena - Rank | `pvpArena` |
|
115
115
|
| Soul Wars Zeal | `soulWarsZeal` |
|
116
|
-
| Rifts
|
116
|
+
| Rifts closed | `riftsClosed` |
|
117
117
|
|
118
118
|
### Leagues
|
119
119
|
|
@@ -156,7 +156,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
156
156
|
| K'ril Tsutsaroth | `krilTsutsaroth` |
|
157
157
|
| Mimic | `mimic` |
|
158
158
|
| Nex | `nex` |
|
159
|
-
|
|
159
|
+
| Nightmare | `nightmare` |
|
160
160
|
| Phosani's Nightmare | `phosanisNightmare` |
|
161
161
|
| Obor | `obor` |
|
162
162
|
| Phantom Muspah | `phantomMuspah` |
|
package/lib/hiscores.d.ts
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
2
|
-
import { Player, Stats, Gamemode, SkillName, PlayerSkillRow, ActivityName, PlayerActivityRow, GetStatsOptions } from './types';
|
2
|
+
import { Player, Stats, Gamemode, SkillName, PlayerSkillRow, ActivityName, PlayerActivityRow, GetStatsOptions, HiscoresResponse } from './types';
|
3
|
+
/**
|
4
|
+
* Gets a player's stats from the official OSRS JSON endpoint.
|
5
|
+
*
|
6
|
+
* @param rsn Username of the player.
|
7
|
+
* @param mode Gamemode to fetch ranks for.
|
8
|
+
* @param config Optional axios request config object.
|
9
|
+
* @returns Official JSON stats object.
|
10
|
+
*/
|
11
|
+
export declare function getOfficialStats(rsn: string, mode?: Gamemode, config?: AxiosRequestConfig): Promise<HiscoresResponse>;
|
3
12
|
/**
|
4
13
|
* Screen scrapes the hiscores to get the formatted rsn of a player.
|
5
14
|
*
|
@@ -8,6 +17,13 @@ import { Player, Stats, Gamemode, SkillName, PlayerSkillRow, ActivityName, Playe
|
|
8
17
|
* @returns Formatted version of the rsn.
|
9
18
|
*/
|
10
19
|
export declare function getRSNFormat(rsn: string, config?: AxiosRequestConfig): Promise<string>;
|
20
|
+
/**
|
21
|
+
* Parses official JSON object of raw stats and returns a stats object.
|
22
|
+
*
|
23
|
+
* @param csv Raw JSON from the official OSRS API.
|
24
|
+
* @returns Parsed stats object.
|
25
|
+
*/
|
26
|
+
export declare function parseJsonStats(json: HiscoresResponse): Stats;
|
11
27
|
/**
|
12
28
|
* Parses CSV string of raw stats and returns a stats object.
|
13
29
|
*
|
package/lib/hiscores.js
CHANGED
@@ -47,9 +47,42 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
47
47
|
}
|
48
48
|
};
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
50
|
-
exports.getActivityPage = exports.getSkillPage = exports.getStatsByGamemode = exports.getStats = exports.parseStats = exports.getRSNFormat = void 0;
|
50
|
+
exports.getActivityPage = exports.getSkillPage = exports.getStatsByGamemode = exports.getStats = exports.parseStats = exports.parseJsonStats = exports.getRSNFormat = exports.getOfficialStats = void 0;
|
51
51
|
var jsdom_1 = require("jsdom");
|
52
52
|
var utils_1 = require("./utils");
|
53
|
+
/**
|
54
|
+
* Gets a player's stats from the official OSRS JSON endpoint.
|
55
|
+
*
|
56
|
+
* @param rsn Username of the player.
|
57
|
+
* @param mode Gamemode to fetch ranks for.
|
58
|
+
* @param config Optional axios request config object.
|
59
|
+
* @returns Official JSON stats object.
|
60
|
+
*/
|
61
|
+
function getOfficialStats(rsn, mode, config) {
|
62
|
+
if (mode === void 0) { mode = 'main'; }
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
64
|
+
var url, response, _a;
|
65
|
+
return __generator(this, function (_b) {
|
66
|
+
switch (_b.label) {
|
67
|
+
case 0:
|
68
|
+
(0, utils_1.validateRSN)(rsn);
|
69
|
+
url = (0, utils_1.getStatsURL)(mode, rsn, true);
|
70
|
+
_b.label = 1;
|
71
|
+
case 1:
|
72
|
+
_b.trys.push([1, 3, , 4]);
|
73
|
+
return [4 /*yield*/, (0, utils_1.httpGet)(url, config)];
|
74
|
+
case 2:
|
75
|
+
response = _b.sent();
|
76
|
+
return [2 /*return*/, response.data];
|
77
|
+
case 3:
|
78
|
+
_a = _b.sent();
|
79
|
+
throw Error(utils_1.PLAYER_NOT_FOUND_ERROR);
|
80
|
+
case 4: return [2 /*return*/];
|
81
|
+
}
|
82
|
+
});
|
83
|
+
});
|
84
|
+
}
|
85
|
+
exports.getOfficialStats = getOfficialStats;
|
53
86
|
/**
|
54
87
|
* Screen scrapes the hiscores to get the formatted rsn of a player.
|
55
88
|
*
|
@@ -76,16 +109,79 @@ function getRSNFormat(rsn, config) {
|
|
76
109
|
if (anchor) {
|
77
110
|
return [2 /*return*/, (0, utils_1.rsnFromElement)(anchor)];
|
78
111
|
}
|
79
|
-
throw Error(
|
112
|
+
throw Error(utils_1.PLAYER_NOT_FOUND_ERROR);
|
80
113
|
case 3:
|
81
114
|
_a = _b.sent();
|
82
|
-
throw Error(
|
115
|
+
throw Error(utils_1.PLAYER_NOT_FOUND_ERROR);
|
83
116
|
case 4: return [2 /*return*/];
|
84
117
|
}
|
85
118
|
});
|
86
119
|
});
|
87
120
|
}
|
88
121
|
exports.getRSNFormat = getRSNFormat;
|
122
|
+
/**
|
123
|
+
* Parses official JSON object of raw stats and returns a stats object.
|
124
|
+
*
|
125
|
+
* @param csv Raw JSON from the official OSRS API.
|
126
|
+
* @returns Parsed stats object.
|
127
|
+
*/
|
128
|
+
function parseJsonStats(json) {
|
129
|
+
var getActivity = function (formattedName) {
|
130
|
+
var _a, _b;
|
131
|
+
var hiscoresActivity = json.activities.find(
|
132
|
+
// We must match on name here since id is not guaranteed to be the same between updates
|
133
|
+
function (_a) {
|
134
|
+
var name = _a.name;
|
135
|
+
return name.toLowerCase() === formattedName.toLowerCase();
|
136
|
+
});
|
137
|
+
return {
|
138
|
+
rank: (_a = hiscoresActivity === null || hiscoresActivity === void 0 ? void 0 : hiscoresActivity.rank) !== null && _a !== void 0 ? _a : -1,
|
139
|
+
score: (_b = hiscoresActivity === null || hiscoresActivity === void 0 ? void 0 : hiscoresActivity.score) !== null && _b !== void 0 ? _b : -1
|
140
|
+
};
|
141
|
+
};
|
142
|
+
var reduceActivity = function (keys, formattedNames) {
|
143
|
+
return keys.reduce(function (reducer, key) {
|
144
|
+
var _a;
|
145
|
+
return (__assign(__assign({}, reducer), (_a = {}, _a[key] = getActivity(formattedNames[key]), _a)));
|
146
|
+
}, {});
|
147
|
+
};
|
148
|
+
var skills = utils_1.SKILLS.reduce(function (skillsObject, skillName) {
|
149
|
+
var _a;
|
150
|
+
var _b, _c, _d;
|
151
|
+
var hiscoresSkill = json.skills.find(
|
152
|
+
// We must match on name here since id is not guaranteed to be the same between updates
|
153
|
+
function (_a) {
|
154
|
+
var name = _a.name;
|
155
|
+
return name.toLowerCase() === utils_1.FORMATTED_SKILL_NAMES[skillName].toLowerCase();
|
156
|
+
});
|
157
|
+
return __assign(__assign({}, skillsObject), (_a = {}, _a[skillName] = {
|
158
|
+
rank: (_b = hiscoresSkill === null || hiscoresSkill === void 0 ? void 0 : hiscoresSkill.rank) !== null && _b !== void 0 ? _b : -1,
|
159
|
+
level: (_c = hiscoresSkill === null || hiscoresSkill === void 0 ? void 0 : hiscoresSkill.level) !== null && _c !== void 0 ? _c : -1,
|
160
|
+
xp: (_d = hiscoresSkill === null || hiscoresSkill === void 0 ? void 0 : hiscoresSkill.xp) !== null && _d !== void 0 ? _d : -1
|
161
|
+
}, _a));
|
162
|
+
}, {});
|
163
|
+
var bountyHunter = reduceActivity(utils_1.BH_MODES, utils_1.FORMATTED_BH_NAMES);
|
164
|
+
var clues = reduceActivity(utils_1.CLUES, utils_1.FORMATTED_CLUE_NAMES);
|
165
|
+
var bosses = reduceActivity(utils_1.BOSSES, utils_1.FORMATTED_BOSS_NAMES);
|
166
|
+
var leaguePoints = getActivity(utils_1.FORMATTED_LEAGUE_POINTS);
|
167
|
+
var lastManStanding = getActivity(utils_1.FORMATTED_LMS);
|
168
|
+
var pvpArena = getActivity(utils_1.FORMATTED_PVP_ARENA);
|
169
|
+
var soulWarsZeal = getActivity(utils_1.FORMATTED_SOUL_WARS);
|
170
|
+
var riftsClosed = getActivity(utils_1.FORMATTED_RIFTS_CLOSED);
|
171
|
+
var stats = {
|
172
|
+
skills: skills,
|
173
|
+
leaguePoints: leaguePoints,
|
174
|
+
bountyHunter: bountyHunter,
|
175
|
+
lastManStanding: lastManStanding,
|
176
|
+
pvpArena: pvpArena,
|
177
|
+
soulWarsZeal: soulWarsZeal,
|
178
|
+
riftsClosed: riftsClosed,
|
179
|
+
clues: clues,
|
180
|
+
bosses: bosses
|
181
|
+
};
|
182
|
+
return stats;
|
183
|
+
}
|
184
|
+
exports.parseJsonStats = parseJsonStats;
|
89
185
|
/**
|
90
186
|
* Parses CSV string of raw stats and returns a stats object.
|
91
187
|
*
|
@@ -185,13 +281,13 @@ function getStats(rsn, options) {
|
|
185
281
|
'ultimate'
|
186
282
|
];
|
187
283
|
shouldGetFormattedRsn = (_b = options === null || options === void 0 ? void 0 : options.shouldGetFormattedRsn) !== null && _b !== void 0 ? _b : true;
|
188
|
-
return [4 /*yield*/, (0, utils_1.httpGet)((0, utils_1.getStatsURL)('main', rsn), (_c = options === null || options === void 0 ? void 0 : options.axiosConfigs) === null || _c === void 0 ? void 0 : _c.main)];
|
284
|
+
return [4 /*yield*/, (0, utils_1.httpGet)((0, utils_1.getStatsURL)('main', rsn, true), (_c = options === null || options === void 0 ? void 0 : options.axiosConfigs) === null || _c === void 0 ? void 0 : _c.main)];
|
189
285
|
case 1:
|
190
286
|
mainRes = _f.sent();
|
191
287
|
if (!(mainRes.status === 200)) return [3 /*break*/, 9];
|
192
288
|
emptyResponse_1 = {
|
193
289
|
status: 404,
|
194
|
-
data:
|
290
|
+
data: { skills: [], activities: [] },
|
195
291
|
statusText: '',
|
196
292
|
headers: {},
|
197
293
|
config: {}
|
@@ -200,7 +296,7 @@ function getStats(rsn, options) {
|
|
200
296
|
var _a;
|
201
297
|
return __generator(this, function (_b) {
|
202
298
|
return [2 /*return*/, otherGamemodes.includes(mode)
|
203
|
-
? (0, utils_1.httpGet)((0, utils_1.getStatsURL)(mode, rsn), (_a = options === null || options === void 0 ? void 0 : options.axiosConfigs) === null || _a === void 0 ? void 0 : _a[mode]).catch(function (err) { return err; })
|
299
|
+
? (0, utils_1.httpGet)((0, utils_1.getStatsURL)(mode, rsn, true), (_a = options === null || options === void 0 ? void 0 : options.axiosConfigs) === null || _a === void 0 ? void 0 : _a[mode]).catch(function (err) { return err; })
|
204
300
|
: emptyResponse_1];
|
205
301
|
});
|
206
302
|
}); };
|
@@ -221,12 +317,12 @@ function getStats(rsn, options) {
|
|
221
317
|
deulted: false,
|
222
318
|
deironed: false
|
223
319
|
};
|
224
|
-
player.main =
|
320
|
+
player.main = parseJsonStats(mainRes.data);
|
225
321
|
return [4 /*yield*/, getModeStats('ironman')];
|
226
322
|
case 5:
|
227
323
|
ironRes = _f.sent();
|
228
324
|
if (!(ironRes.status === 200)) return [3 /*break*/, 8];
|
229
|
-
player.ironman =
|
325
|
+
player.ironman = parseJsonStats(ironRes.data);
|
230
326
|
return [4 /*yield*/, getModeStats('hardcore')];
|
231
327
|
case 6:
|
232
328
|
hcRes = _f.sent();
|
@@ -235,7 +331,7 @@ function getStats(rsn, options) {
|
|
235
331
|
ultRes = _f.sent();
|
236
332
|
if (hcRes.status === 200) {
|
237
333
|
player.mode = 'hardcore';
|
238
|
-
player.hardcore =
|
334
|
+
player.hardcore = parseJsonStats(hcRes.data);
|
239
335
|
if (player.ironman.skills.overall.xp !== player.hardcore.skills.overall.xp) {
|
240
336
|
player.dead = true;
|
241
337
|
player.mode = 'ironman';
|
@@ -247,7 +343,7 @@ function getStats(rsn, options) {
|
|
247
343
|
}
|
248
344
|
else if (ultRes.status === 200) {
|
249
345
|
player.mode = 'ultimate';
|
250
|
-
player.ultimate =
|
346
|
+
player.ultimate = parseJsonStats(ultRes.data);
|
251
347
|
if (player.ironman.skills.overall.xp !== player.ultimate.skills.overall.xp) {
|
252
348
|
player.deulted = true;
|
253
349
|
player.mode = 'ironman';
|
@@ -266,7 +362,7 @@ function getStats(rsn, options) {
|
|
266
362
|
}
|
267
363
|
_f.label = 8;
|
268
364
|
case 8: return [2 /*return*/, player];
|
269
|
-
case 9: throw Error(
|
365
|
+
case 9: throw Error(utils_1.PLAYER_NOT_FOUND_ERROR);
|
270
366
|
}
|
271
367
|
});
|
272
368
|
});
|
@@ -291,13 +387,10 @@ function getStatsByGamemode(rsn, mode, config) {
|
|
291
387
|
if (!utils_1.GAMEMODES.includes(mode)) {
|
292
388
|
throw Error('Invalid game mode');
|
293
389
|
}
|
294
|
-
return [4 /*yield*/, (
|
390
|
+
return [4 /*yield*/, getOfficialStats(rsn, mode, config)];
|
295
391
|
case 1:
|
296
392
|
response = _a.sent();
|
297
|
-
|
298
|
-
throw Error('Player not found');
|
299
|
-
}
|
300
|
-
stats = parseStats(response.data);
|
393
|
+
stats = parseJsonStats(response);
|
301
394
|
return [2 /*return*/, stats];
|
302
395
|
}
|
303
396
|
});
|
package/lib/types.d.ts
CHANGED
@@ -76,3 +76,37 @@ export interface GetStatsOptions {
|
|
76
76
|
rsn?: AxiosRequestConfig;
|
77
77
|
};
|
78
78
|
}
|
79
|
+
export interface HiscoresCommon {
|
80
|
+
/**
|
81
|
+
* This field behaves more like an index than a true unique ID.
|
82
|
+
*/
|
83
|
+
id: number;
|
84
|
+
/**
|
85
|
+
* The display name of this skill / activity.
|
86
|
+
*/
|
87
|
+
name: string;
|
88
|
+
/**
|
89
|
+
* The player's official hiscores rank in this skill / activity.
|
90
|
+
*/
|
91
|
+
rank: number;
|
92
|
+
}
|
93
|
+
export interface HiscoresSkill extends HiscoresCommon {
|
94
|
+
/**
|
95
|
+
* The player's current level in this skill.
|
96
|
+
*/
|
97
|
+
level: number;
|
98
|
+
/**
|
99
|
+
* The player's current experience in this skill.
|
100
|
+
*/
|
101
|
+
xp: number;
|
102
|
+
}
|
103
|
+
export interface HiscoresActivity extends HiscoresCommon {
|
104
|
+
/**
|
105
|
+
* The player's current score in this activity.
|
106
|
+
*/
|
107
|
+
score: number;
|
108
|
+
}
|
109
|
+
export interface HiscoresResponse {
|
110
|
+
skills: HiscoresSkill[];
|
111
|
+
activities: HiscoresActivity[];
|
112
|
+
}
|
package/lib/utils/constants.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { BHType, Boss, ClueType, Gamemode, SkillName, ActivityName } from '../types';
|
2
2
|
export declare const BASE_URL = "https://secure.runescape.com/m=hiscore_oldschool";
|
3
3
|
export declare const STATS_URL = "index_lite.ws?player=";
|
4
|
+
export declare const JSON_STATS_URL = "index_lite.json?player=";
|
4
5
|
export declare const SCORES_URL = "overall.ws?";
|
5
6
|
export type GamemodeUrl = {
|
6
7
|
[key in Gamemode]: string;
|
@@ -28,9 +29,10 @@ export type FormattedBHNames = {
|
|
28
29
|
[key in BHType]: string;
|
29
30
|
};
|
30
31
|
export declare const FORMATTED_BH_NAMES: FormattedBHNames;
|
31
|
-
export declare const FORMATTED_LMS = "
|
32
|
-
export declare const FORMATTED_PVP_ARENA = "PvP Arena";
|
32
|
+
export declare const FORMATTED_LMS = "LMS - Rank";
|
33
|
+
export declare const FORMATTED_PVP_ARENA = "PvP Arena - Rank";
|
33
34
|
export declare const FORMATTED_SOUL_WARS = "Soul Wars Zeal";
|
34
35
|
export declare const FORMATTED_LEAGUE_POINTS = "League Points";
|
35
|
-
export declare const FORMATTED_RIFTS_CLOSED = "Rifts
|
36
|
+
export declare const FORMATTED_RIFTS_CLOSED = "Rifts closed";
|
36
37
|
export declare const INVALID_FORMAT_ERROR = "Invalid hiscores format";
|
38
|
+
export declare const PLAYER_NOT_FOUND_ERROR = "Player not found";
|
package/lib/utils/constants.js
CHANGED
@@ -9,9 +9,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
9
9
|
return to.concat(ar || Array.prototype.slice.call(from));
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.INVALID_FORMAT_ERROR = exports.FORMATTED_RIFTS_CLOSED = exports.FORMATTED_LEAGUE_POINTS = exports.FORMATTED_SOUL_WARS = exports.FORMATTED_PVP_ARENA = exports.FORMATTED_LMS = exports.FORMATTED_BH_NAMES = exports.FORMATTED_CLUE_NAMES = exports.FORMATTED_SKILL_NAMES = exports.FORMATTED_BOSS_NAMES = exports.ACTIVITIES = exports.BOSSES = exports.GAMEMODES = exports.BH_MODES = exports.CLUES = exports.SKILLS = exports.GAMEMODE_URL = exports.SCORES_URL = exports.STATS_URL = exports.BASE_URL = void 0;
|
12
|
+
exports.PLAYER_NOT_FOUND_ERROR = exports.INVALID_FORMAT_ERROR = exports.FORMATTED_RIFTS_CLOSED = exports.FORMATTED_LEAGUE_POINTS = exports.FORMATTED_SOUL_WARS = exports.FORMATTED_PVP_ARENA = exports.FORMATTED_LMS = exports.FORMATTED_BH_NAMES = exports.FORMATTED_CLUE_NAMES = exports.FORMATTED_SKILL_NAMES = exports.FORMATTED_BOSS_NAMES = exports.ACTIVITIES = exports.BOSSES = exports.GAMEMODES = exports.BH_MODES = exports.CLUES = exports.SKILLS = exports.GAMEMODE_URL = exports.SCORES_URL = exports.JSON_STATS_URL = exports.STATS_URL = exports.BASE_URL = void 0;
|
13
13
|
exports.BASE_URL = 'https://secure.runescape.com/m=hiscore_oldschool';
|
14
14
|
exports.STATS_URL = 'index_lite.ws?player=';
|
15
|
+
exports.JSON_STATS_URL = 'index_lite.json?player=';
|
15
16
|
exports.SCORES_URL = 'overall.ws?';
|
16
17
|
exports.GAMEMODE_URL = {
|
17
18
|
main: "".concat(exports.BASE_URL, "/"),
|
@@ -180,7 +181,7 @@ exports.FORMATTED_BOSS_NAMES = {
|
|
180
181
|
krilTsutsaroth: "K'ril Tsutsaroth",
|
181
182
|
mimic: 'Mimic',
|
182
183
|
nex: 'Nex',
|
183
|
-
nightmare: '
|
184
|
+
nightmare: 'Nightmare',
|
184
185
|
phosanisNightmare: "Phosani's Nightmare",
|
185
186
|
obor: 'Obor',
|
186
187
|
phantomMuspah: 'Phantom Muspah',
|
@@ -249,9 +250,10 @@ exports.FORMATTED_BH_NAMES = {
|
|
249
250
|
rogueV2: 'Bounty Hunter - Rogue',
|
250
251
|
hunterV2: 'Bounty Hunter - Hunter'
|
251
252
|
};
|
252
|
-
exports.FORMATTED_LMS = '
|
253
|
-
exports.FORMATTED_PVP_ARENA = 'PvP Arena';
|
253
|
+
exports.FORMATTED_LMS = 'LMS - Rank';
|
254
|
+
exports.FORMATTED_PVP_ARENA = 'PvP Arena - Rank';
|
254
255
|
exports.FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
|
255
256
|
exports.FORMATTED_LEAGUE_POINTS = 'League Points';
|
256
|
-
exports.FORMATTED_RIFTS_CLOSED = 'Rifts
|
257
|
+
exports.FORMATTED_RIFTS_CLOSED = 'Rifts closed';
|
257
258
|
exports.INVALID_FORMAT_ERROR = 'Invalid hiscores format';
|
259
|
+
exports.PLAYER_NOT_FOUND_ERROR = 'Player not found';
|
package/lib/utils/helpers.d.ts
CHANGED
@@ -5,9 +5,10 @@ import { Gamemode, SkillName, ActivityName } from '../types';
|
|
5
5
|
*
|
6
6
|
* @param gamemode Gamemode to fetch ranks for.
|
7
7
|
* @param rsn Username of the player.
|
8
|
+
* @param json If the JSON endpoint is desired instead of CSV.
|
8
9
|
* @returns Encoded stats URL.
|
9
10
|
*/
|
10
|
-
export declare const getStatsURL: (gamemode: Gamemode, rsn: string) => string;
|
11
|
+
export declare const getStatsURL: (gamemode: Gamemode, rsn: string, json?: boolean) => string;
|
11
12
|
/**
|
12
13
|
* Will generate a player table URL for the official OSRS hiscores website.
|
13
14
|
*
|
package/lib/utils/helpers.js
CHANGED
@@ -20,10 +20,12 @@ var constants_1 = require("./constants");
|
|
20
20
|
*
|
21
21
|
* @param gamemode Gamemode to fetch ranks for.
|
22
22
|
* @param rsn Username of the player.
|
23
|
+
* @param json If the JSON endpoint is desired instead of CSV.
|
23
24
|
* @returns Encoded stats URL.
|
24
25
|
*/
|
25
|
-
var getStatsURL = function (gamemode, rsn) {
|
26
|
-
|
26
|
+
var getStatsURL = function (gamemode, rsn, json) {
|
27
|
+
if (json === void 0) { json = false; }
|
28
|
+
return "".concat(constants_1.GAMEMODE_URL[gamemode]).concat(json ? constants_1.JSON_STATS_URL : constants_1.STATS_URL).concat(encodeURIComponent(rsn));
|
27
29
|
};
|
28
30
|
exports.getStatsURL = getStatsURL;
|
29
31
|
/**
|