osrs-json-hiscores 2.5.2 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -4
- package/README.md +221 -217
- package/lib/hiscores.d.ts +43 -43
- package/lib/hiscores.js +388 -384
- package/lib/index.d.ts +5 -5
- package/lib/index.js +17 -17
- package/lib/types.d.ts +55 -54
- package/lib/types.js +2 -2
- package/lib/utils/constants.d.ts +35 -33
- package/lib/utils/constants.js +224 -217
- package/lib/utils/helpers.d.ts +56 -56
- package/lib/utils/helpers.js +92 -92
- package/lib/utils/index.d.ts +2 -2
- package/lib/utils/index.js +14 -14
- package/package.json +114 -114
package/lib/utils/helpers.js
CHANGED
@@ -1,92 +1,92 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.httpGet = exports.rsnFromElement = exports.numberFromElement = exports.getActivityPageURL = exports.getSkillPageURL = exports.getPlayerTableURL = exports.getStatsURL = void 0;
|
4
|
-
var axios_1 = require("axios");
|
5
|
-
var ua = require("useragent-generator");
|
6
|
-
var constants_1 = require("./constants");
|
7
|
-
/**
|
8
|
-
* Will generate a stats URL for the official OSRS API.
|
9
|
-
*
|
10
|
-
* @param gamemode Gamemode to fetch ranks for.
|
11
|
-
* @param rsn Username of the player.
|
12
|
-
* @returns Encoded stats URL.
|
13
|
-
*/
|
14
|
-
var getStatsURL = function (gamemode, rsn) {
|
15
|
-
return "" + constants_1.GAMEMODE_URL[gamemode] + constants_1.STATS_URL + encodeURIComponent(rsn);
|
16
|
-
};
|
17
|
-
exports.getStatsURL = getStatsURL;
|
18
|
-
/**
|
19
|
-
* Will generate a player table URL for the official OSRS hiscores website.
|
20
|
-
*
|
21
|
-
* @param gamemode Gamemode to fetch ranks for.
|
22
|
-
* @param rsn Username of the player.
|
23
|
-
* @returns Encoded player table URL.
|
24
|
-
*/
|
25
|
-
var getPlayerTableURL = function (gamemode, rsn) {
|
26
|
-
return "" + constants_1.GAMEMODE_URL[gamemode] + constants_1.SCORES_URL + "table=0&user=" + encodeURIComponent(rsn);
|
27
|
-
};
|
28
|
-
exports.getPlayerTableURL = getPlayerTableURL;
|
29
|
-
/**
|
30
|
-
* Will generate a skill table URL for the official OSRS hiscores website.
|
31
|
-
*
|
32
|
-
* @param gamemode Gamemode to fetch ranks for.
|
33
|
-
* @param skill Skill to fetch ranks for.
|
34
|
-
* @param page Page number.
|
35
|
-
* @returns
|
36
|
-
*/
|
37
|
-
var getSkillPageURL = function (gamemode, skill, page) {
|
38
|
-
return "" + constants_1.GAMEMODE_URL[gamemode] + constants_1.SCORES_URL + "table=" + constants_1.SKILLS.indexOf(skill) + "&page=" + page;
|
39
|
-
};
|
40
|
-
exports.getSkillPageURL = getSkillPageURL;
|
41
|
-
/**
|
42
|
-
* Will generate an activity table URL for the official OSRS hiscores website.
|
43
|
-
*
|
44
|
-
* @param gamemode Gamemode to fetch ranks for.
|
45
|
-
* @param activity Activity or boss to fetch ranks for.
|
46
|
-
* @param page Page number.
|
47
|
-
* @returns
|
48
|
-
*/
|
49
|
-
var getActivityPageURL = function (gamemode, activity, page) {
|
50
|
-
return "" + constants_1.GAMEMODE_URL[gamemode] + constants_1.SCORES_URL + "category_type=1&table=" + constants_1.ACTIVITIES.indexOf(activity) + "&page=" + page;
|
51
|
-
};
|
52
|
-
exports.getActivityPageURL = getActivityPageURL;
|
53
|
-
/**
|
54
|
-
* Extracts a number from an OSRS hiscores table cell element.
|
55
|
-
*
|
56
|
-
* @param el OSRS hiscores table cell element.
|
57
|
-
* @returns Number parsed from cell text.
|
58
|
-
*/
|
59
|
-
var numberFromElement = function (el) {
|
60
|
-
var _a;
|
61
|
-
var innerHTML = (el !== null && el !== void 0 ? el : {}).innerHTML;
|
62
|
-
var number = (_a = innerHTML === null || innerHTML === void 0 ? void 0 : innerHTML.replace(/[\n|,]/g, '')) !== null && _a !== void 0 ? _a : '-1';
|
63
|
-
return parseInt(number, 10);
|
64
|
-
};
|
65
|
-
exports.numberFromElement = numberFromElement;
|
66
|
-
/**
|
67
|
-
* Extracts a RSN from an OSRS hiscores table cell element.
|
68
|
-
*
|
69
|
-
* @param el OSRS hiscores table cell element.
|
70
|
-
* @returns RSN parsed from cell text.
|
71
|
-
*/
|
72
|
-
var rsnFromElement = function (el) {
|
73
|
-
var _a;
|
74
|
-
var innerHTML = (el !== null && el !== void 0 ? el : {}).innerHTML;
|
75
|
-
return (_a = innerHTML === null || innerHTML === void 0 ? void 0 : innerHTML.replace(/\uFFFD/g, ' ')) !== null && _a !== void 0 ? _a : '';
|
76
|
-
};
|
77
|
-
exports.rsnFromElement = rsnFromElement;
|
78
|
-
/**
|
79
|
-
* Will run an Axios `GET` request against a given URL after injecting a `User-Agent` header.
|
80
|
-
*
|
81
|
-
* @param url URL to run a `GET` request against.
|
82
|
-
* @returns Axios response.
|
83
|
-
*/
|
84
|
-
var httpGet = function (url) {
|
85
|
-
return axios_1.default.get(url, {
|
86
|
-
headers: {
|
87
|
-
// without User-Agent header requests may be rejected by DDoS protection mechanism
|
88
|
-
'User-Agent': ua.firefox(80)
|
89
|
-
}
|
90
|
-
});
|
91
|
-
};
|
92
|
-
exports.httpGet = httpGet;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.httpGet = exports.rsnFromElement = exports.numberFromElement = exports.getActivityPageURL = exports.getSkillPageURL = exports.getPlayerTableURL = exports.getStatsURL = void 0;
|
4
|
+
var axios_1 = require("axios");
|
5
|
+
var ua = require("useragent-generator");
|
6
|
+
var constants_1 = require("./constants");
|
7
|
+
/**
|
8
|
+
* Will generate a stats URL for the official OSRS API.
|
9
|
+
*
|
10
|
+
* @param gamemode Gamemode to fetch ranks for.
|
11
|
+
* @param rsn Username of the player.
|
12
|
+
* @returns Encoded stats URL.
|
13
|
+
*/
|
14
|
+
var getStatsURL = function (gamemode, rsn) {
|
15
|
+
return "" + constants_1.GAMEMODE_URL[gamemode] + constants_1.STATS_URL + encodeURIComponent(rsn);
|
16
|
+
};
|
17
|
+
exports.getStatsURL = getStatsURL;
|
18
|
+
/**
|
19
|
+
* Will generate a player table URL for the official OSRS hiscores website.
|
20
|
+
*
|
21
|
+
* @param gamemode Gamemode to fetch ranks for.
|
22
|
+
* @param rsn Username of the player.
|
23
|
+
* @returns Encoded player table URL.
|
24
|
+
*/
|
25
|
+
var getPlayerTableURL = function (gamemode, rsn) {
|
26
|
+
return "" + constants_1.GAMEMODE_URL[gamemode] + constants_1.SCORES_URL + "table=0&user=" + encodeURIComponent(rsn);
|
27
|
+
};
|
28
|
+
exports.getPlayerTableURL = getPlayerTableURL;
|
29
|
+
/**
|
30
|
+
* Will generate a skill table URL for the official OSRS hiscores website.
|
31
|
+
*
|
32
|
+
* @param gamemode Gamemode to fetch ranks for.
|
33
|
+
* @param skill Skill to fetch ranks for.
|
34
|
+
* @param page Page number.
|
35
|
+
* @returns
|
36
|
+
*/
|
37
|
+
var getSkillPageURL = function (gamemode, skill, page) {
|
38
|
+
return "" + constants_1.GAMEMODE_URL[gamemode] + constants_1.SCORES_URL + "table=" + constants_1.SKILLS.indexOf(skill) + "&page=" + page;
|
39
|
+
};
|
40
|
+
exports.getSkillPageURL = getSkillPageURL;
|
41
|
+
/**
|
42
|
+
* Will generate an activity table URL for the official OSRS hiscores website.
|
43
|
+
*
|
44
|
+
* @param gamemode Gamemode to fetch ranks for.
|
45
|
+
* @param activity Activity or boss to fetch ranks for.
|
46
|
+
* @param page Page number.
|
47
|
+
* @returns
|
48
|
+
*/
|
49
|
+
var getActivityPageURL = function (gamemode, activity, page) {
|
50
|
+
return "" + constants_1.GAMEMODE_URL[gamemode] + constants_1.SCORES_URL + "category_type=1&table=" + constants_1.ACTIVITIES.indexOf(activity) + "&page=" + page;
|
51
|
+
};
|
52
|
+
exports.getActivityPageURL = getActivityPageURL;
|
53
|
+
/**
|
54
|
+
* Extracts a number from an OSRS hiscores table cell element.
|
55
|
+
*
|
56
|
+
* @param el OSRS hiscores table cell element.
|
57
|
+
* @returns Number parsed from cell text.
|
58
|
+
*/
|
59
|
+
var numberFromElement = function (el) {
|
60
|
+
var _a;
|
61
|
+
var innerHTML = (el !== null && el !== void 0 ? el : {}).innerHTML;
|
62
|
+
var number = (_a = innerHTML === null || innerHTML === void 0 ? void 0 : innerHTML.replace(/[\n|,]/g, '')) !== null && _a !== void 0 ? _a : '-1';
|
63
|
+
return parseInt(number, 10);
|
64
|
+
};
|
65
|
+
exports.numberFromElement = numberFromElement;
|
66
|
+
/**
|
67
|
+
* Extracts a RSN from an OSRS hiscores table cell element.
|
68
|
+
*
|
69
|
+
* @param el OSRS hiscores table cell element.
|
70
|
+
* @returns RSN parsed from cell text.
|
71
|
+
*/
|
72
|
+
var rsnFromElement = function (el) {
|
73
|
+
var _a;
|
74
|
+
var innerHTML = (el !== null && el !== void 0 ? el : {}).innerHTML;
|
75
|
+
return (_a = innerHTML === null || innerHTML === void 0 ? void 0 : innerHTML.replace(/\uFFFD/g, ' ')) !== null && _a !== void 0 ? _a : '';
|
76
|
+
};
|
77
|
+
exports.rsnFromElement = rsnFromElement;
|
78
|
+
/**
|
79
|
+
* Will run an Axios `GET` request against a given URL after injecting a `User-Agent` header.
|
80
|
+
*
|
81
|
+
* @param url URL to run a `GET` request against.
|
82
|
+
* @returns Axios response.
|
83
|
+
*/
|
84
|
+
var httpGet = function (url) {
|
85
|
+
return axios_1.default.get(url, {
|
86
|
+
headers: {
|
87
|
+
// without User-Agent header requests may be rejected by DDoS protection mechanism
|
88
|
+
'User-Agent': ua.firefox(80)
|
89
|
+
}
|
90
|
+
});
|
91
|
+
};
|
92
|
+
exports.httpGet = httpGet;
|
package/lib/utils/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from './constants';
|
2
|
-
export * from './helpers';
|
1
|
+
export * from './constants';
|
2
|
+
export * from './helpers';
|
package/lib/utils/index.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
-
}) : (function(o, m, k, k2) {
|
6
|
-
if (k2 === undefined) k2 = k;
|
7
|
-
o[k2] = m[k];
|
8
|
-
}));
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
11
|
-
};
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
-
__exportStar(require("./constants"), exports);
|
14
|
-
__exportStar(require("./helpers"), exports);
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
__exportStar(require("./constants"), exports);
|
14
|
+
__exportStar(require("./helpers"), exports);
|
package/package.json
CHANGED
@@ -1,114 +1,114 @@
|
|
1
|
-
{
|
2
|
-
"name": "osrs-json-hiscores",
|
3
|
-
"version": "2.
|
4
|
-
"description": "The Old School Runescape API wrapper that does more!",
|
5
|
-
"main": "lib/index.js",
|
6
|
-
"types": "lib/index.d.ts",
|
7
|
-
"files": [
|
8
|
-
"lib/**/*"
|
9
|
-
],
|
10
|
-
"scripts": {
|
11
|
-
"dev": "yarn build --watch",
|
12
|
-
"build": "tsc",
|
13
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
14
|
-
"lint": "eslint --fix \"src/**/*.ts\"",
|
15
|
-
"test": "jest",
|
16
|
-
"prepublish": "yarn run build",
|
17
|
-
"release": "np"
|
18
|
-
},
|
19
|
-
"repository": {
|
20
|
-
"type": "git",
|
21
|
-
"url": "git+https://github.com/maxswa/osrs-json-hiscores.git"
|
22
|
-
},
|
23
|
-
"keywords": [
|
24
|
-
"oldschool",
|
25
|
-
"runescape",
|
26
|
-
"osrs",
|
27
|
-
"api",
|
28
|
-
"json",
|
29
|
-
"hiscores",
|
30
|
-
"stats",
|
31
|
-
"skills"
|
32
|
-
],
|
33
|
-
"author": "maxswa",
|
34
|
-
"license": "ISC",
|
35
|
-
"bugs": {
|
36
|
-
"url": "https://github.com/maxswa/osrs-json-hiscores/issues"
|
37
|
-
},
|
38
|
-
"homepage": "https://github.com/maxswa/osrs-json-hiscores#readme",
|
39
|
-
"husky": {
|
40
|
-
"hooks": {
|
41
|
-
"pre-commit": "lint-staged"
|
42
|
-
}
|
43
|
-
},
|
44
|
-
"lint-staged": {
|
45
|
-
"*.{ts}": [
|
46
|
-
"eslint --fix",
|
47
|
-
"prettier --write",
|
48
|
-
"git add"
|
49
|
-
]
|
50
|
-
},
|
51
|
-
"eslintConfig": {
|
52
|
-
"root": true,
|
53
|
-
"parser": "@typescript-eslint/parser",
|
54
|
-
"parserOptions": {
|
55
|
-
"project": "./tsconfig.eslint.json"
|
56
|
-
},
|
57
|
-
"plugins": [
|
58
|
-
"@typescript-eslint"
|
59
|
-
],
|
60
|
-
"extends": [
|
61
|
-
"eslint-config-airbnb-typescript",
|
62
|
-
"prettier"
|
63
|
-
],
|
64
|
-
"ignorePatterns": [
|
65
|
-
"**/@types/*"
|
66
|
-
]
|
67
|
-
},
|
68
|
-
"prettier": {
|
69
|
-
"trailingComma": "none",
|
70
|
-
"tabWidth": 2,
|
71
|
-
"semi": true,
|
72
|
-
"singleQuote": true
|
73
|
-
},
|
74
|
-
"jest": {
|
75
|
-
"transform": {
|
76
|
-
"^.+\\.(t|j)sx?$": "ts-jest"
|
77
|
-
},
|
78
|
-
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
79
|
-
"moduleFileExtensions": [
|
80
|
-
"ts",
|
81
|
-
"tsx",
|
82
|
-
"js",
|
83
|
-
"jsx",
|
84
|
-
"json",
|
85
|
-
"node"
|
86
|
-
],
|
87
|
-
"testEnvironment": "node"
|
88
|
-
},
|
89
|
-
"dependencies": {
|
90
|
-
"axios": "^0.21.1",
|
91
|
-
"jsdom": "^16.3.0",
|
92
|
-
"useragent-generator": "^1.1.0"
|
93
|
-
},
|
94
|
-
"devDependencies": {
|
95
|
-
"@types/jest": "^26.0.21",
|
96
|
-
"@types/jsdom": "^16.2.3",
|
97
|
-
"@typescript-eslint/eslint-plugin": "^4.19.0",
|
98
|
-
"@typescript-eslint/parser": "^4.19.0",
|
99
|
-
"eslint": "^7.22.0",
|
100
|
-
"eslint-config-airbnb-typescript": "^12.3.1",
|
101
|
-
"eslint-config-prettier": "^8.1.0",
|
102
|
-
"eslint-plugin-import": "^2.22.1",
|
103
|
-
"eslint-plugin-jsx-a11y": "^6.4.1",
|
104
|
-
"eslint-plugin-react": "^7.23.1",
|
105
|
-
"eslint-plugin-react-hooks": "^4.2.0",
|
106
|
-
"husky": "^5.2.0",
|
107
|
-
"jest": "^26.6.3",
|
108
|
-
"lint-staged": "^10.5.4",
|
109
|
-
"np": "6.5.0",
|
110
|
-
"prettier": "^2.2.1",
|
111
|
-
"ts-jest": "^26.5.4",
|
112
|
-
"typescript": "^4.2.3"
|
113
|
-
}
|
114
|
-
}
|
1
|
+
{
|
2
|
+
"name": "osrs-json-hiscores",
|
3
|
+
"version": "2.8.0",
|
4
|
+
"description": "The Old School Runescape API wrapper that does more!",
|
5
|
+
"main": "lib/index.js",
|
6
|
+
"types": "lib/index.d.ts",
|
7
|
+
"files": [
|
8
|
+
"lib/**/*"
|
9
|
+
],
|
10
|
+
"scripts": {
|
11
|
+
"dev": "yarn build --watch",
|
12
|
+
"build": "tsc",
|
13
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
14
|
+
"lint": "eslint --fix \"src/**/*.ts\"",
|
15
|
+
"test": "jest",
|
16
|
+
"prepublish": "yarn run build",
|
17
|
+
"release": "np"
|
18
|
+
},
|
19
|
+
"repository": {
|
20
|
+
"type": "git",
|
21
|
+
"url": "git+https://github.com/maxswa/osrs-json-hiscores.git"
|
22
|
+
},
|
23
|
+
"keywords": [
|
24
|
+
"oldschool",
|
25
|
+
"runescape",
|
26
|
+
"osrs",
|
27
|
+
"api",
|
28
|
+
"json",
|
29
|
+
"hiscores",
|
30
|
+
"stats",
|
31
|
+
"skills"
|
32
|
+
],
|
33
|
+
"author": "maxswa",
|
34
|
+
"license": "ISC",
|
35
|
+
"bugs": {
|
36
|
+
"url": "https://github.com/maxswa/osrs-json-hiscores/issues"
|
37
|
+
},
|
38
|
+
"homepage": "https://github.com/maxswa/osrs-json-hiscores#readme",
|
39
|
+
"husky": {
|
40
|
+
"hooks": {
|
41
|
+
"pre-commit": "lint-staged"
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"lint-staged": {
|
45
|
+
"*.{ts}": [
|
46
|
+
"eslint --fix",
|
47
|
+
"prettier --write",
|
48
|
+
"git add"
|
49
|
+
]
|
50
|
+
},
|
51
|
+
"eslintConfig": {
|
52
|
+
"root": true,
|
53
|
+
"parser": "@typescript-eslint/parser",
|
54
|
+
"parserOptions": {
|
55
|
+
"project": "./tsconfig.eslint.json"
|
56
|
+
},
|
57
|
+
"plugins": [
|
58
|
+
"@typescript-eslint"
|
59
|
+
],
|
60
|
+
"extends": [
|
61
|
+
"eslint-config-airbnb-typescript",
|
62
|
+
"prettier"
|
63
|
+
],
|
64
|
+
"ignorePatterns": [
|
65
|
+
"**/@types/*"
|
66
|
+
]
|
67
|
+
},
|
68
|
+
"prettier": {
|
69
|
+
"trailingComma": "none",
|
70
|
+
"tabWidth": 2,
|
71
|
+
"semi": true,
|
72
|
+
"singleQuote": true
|
73
|
+
},
|
74
|
+
"jest": {
|
75
|
+
"transform": {
|
76
|
+
"^.+\\.(t|j)sx?$": "ts-jest"
|
77
|
+
},
|
78
|
+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
79
|
+
"moduleFileExtensions": [
|
80
|
+
"ts",
|
81
|
+
"tsx",
|
82
|
+
"js",
|
83
|
+
"jsx",
|
84
|
+
"json",
|
85
|
+
"node"
|
86
|
+
],
|
87
|
+
"testEnvironment": "node"
|
88
|
+
},
|
89
|
+
"dependencies": {
|
90
|
+
"axios": "^0.21.1",
|
91
|
+
"jsdom": "^16.3.0",
|
92
|
+
"useragent-generator": "^1.1.0"
|
93
|
+
},
|
94
|
+
"devDependencies": {
|
95
|
+
"@types/jest": "^26.0.21",
|
96
|
+
"@types/jsdom": "^16.2.3",
|
97
|
+
"@typescript-eslint/eslint-plugin": "^4.19.0",
|
98
|
+
"@typescript-eslint/parser": "^4.19.0",
|
99
|
+
"eslint": "^7.22.0",
|
100
|
+
"eslint-config-airbnb-typescript": "^12.3.1",
|
101
|
+
"eslint-config-prettier": "^8.1.0",
|
102
|
+
"eslint-plugin-import": "^2.22.1",
|
103
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
104
|
+
"eslint-plugin-react": "^7.23.1",
|
105
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
106
|
+
"husky": "^5.2.0",
|
107
|
+
"jest": "^26.6.3",
|
108
|
+
"lint-staged": "^10.5.4",
|
109
|
+
"np": "6.5.0",
|
110
|
+
"prettier": "^2.2.1",
|
111
|
+
"ts-jest": "^26.5.4",
|
112
|
+
"typescript": "^4.2.3"
|
113
|
+
}
|
114
|
+
}
|