Compare commits

..

25 Commits

Author SHA1 Message Date
maxswa
e77737f422 Add Guardians of the Rift. 2022-04-18 15:44:45 -04:00
Max Swartwout
3a72315498 Merge pull request #49 from maxswa/dependabot/npm_and_yarn/follow-redirects-1.14.8
Bump follow-redirects from 1.14.7 to 1.14.8
2022-02-15 14:37:28 -05:00
dependabot[bot]
c1c9833ad0 Bump follow-redirects from 1.14.7 to 1.14.8
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-12 12:01:29 +00:00
Max Swartwout
9fe03746e1 Merge pull request #48 from maxswa/dependabot/npm_and_yarn/follow-redirects-1.14.7
Bump follow-redirects from 1.14.4 to 1.14.7
2022-01-18 10:42:22 -05:00
dependabot[bot]
66a4fb47a6 Bump follow-redirects from 1.14.4 to 1.14.7
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.4 to 1.14.7.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.4...v1.14.7)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-13 14:22:21 +00:00
Max Swartwout
83c44148a7 Merge pull request #47 from maxswa/fix-tests-nex
Fix tests
2022-01-05 21:54:48 -05:00
maxswa
44dea6b35c Add line for nex in lynxTitanStats.csv 2022-01-05 21:50:28 -05:00
maxswa
0bf491638c v2.7.0 2022-01-05 10:04:11 -05:00
Max Swartwout
febca534b0 Merge pull request #45 from maxswa/add-nex
Add Nex.
2022-01-05 09:57:56 -05:00
Max Swartwout
8daee5c39b Merge pull request #46 from molo-pl/main
Throw error for unknown hiscores CSV format
2022-01-05 09:52:42 -05:00
molo-pl
f98cf8aaaa Throw error for unknown hiscores CSV format 2022-01-04 23:05:34 +01:00
maxswa
5d9f6a6bac Add Nex. 2021-12-19 21:40:09 -05:00
Max Swartwout
8737b50a82 Merge pull request #44 from maxswa/dependabot/npm_and_yarn/axios-0.21.2
Bump axios from 0.21.1 to 0.21.2
2021-09-27 16:38:12 -04:00
dependabot[bot]
1255e7e3d2 Bump axios from 0.21.1 to 0.21.2
Bumps [axios](https://github.com/axios/axios) from 0.21.1 to 0.21.2.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v0.21.1...v0.21.2)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 20:36:33 +00:00
Max Swartwout
f4135d0b0f Merge pull request #42 from maxswa/dependabot/npm_and_yarn/path-parse-1.0.7
Bump path-parse from 1.0.6 to 1.0.7
2021-09-27 16:36:09 -04:00
Max Swartwout
6135ff459c Merge pull request #43 from maxswa/dependabot/npm_and_yarn/tmpl-1.0.5
Bump tmpl from 1.0.4 to 1.0.5
2021-09-27 16:36:00 -04:00
dependabot[bot]
9fb7e4cebc Bump tmpl from 1.0.4 to 1.0.5
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 04:35:18 +00:00
dependabot[bot]
11350b2444 Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-11 02:52:55 +00:00
maxswa
e0d6c5b20f v2.6.0 2021-07-02 10:53:19 -04:00
Max Swartwout
c8a4440ac3 Merge pull request #41 from Not-Jayden/phosanis-nightmare
New Boss: Phosani's Nightmare
2021-07-02 10:49:19 -04:00
Not-Jayden
f3781cf142 add to readme 2021-07-02 18:09:10 +08:00
Not-Jayden
5fbc04217b Merge branch 'phosanis-nightmare' of https://github.com/Not-Jayden/osrs-json-hiscores into phosanis-nightmare 2021-07-02 13:20:45 +08:00
Not-Jayden
eb5d0ba49f add to lynxTitanStats.csv 2021-07-02 13:20:33 +08:00
Not-Jayden
c68e3bebea Update __tests__/hiscores.test.ts 2021-07-02 13:13:07 +08:00
Not-Jayden
aa6fd6f39a add phosani's nightmare to api 2021-07-01 20:14:31 +08:00
8 changed files with 82 additions and 20 deletions

View File

@@ -110,6 +110,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
| Bounty Hunter (Hunter) | `hunterBH` | | Bounty Hunter (Hunter) | `hunterBH` |
| Last Man Standing | `lastManStanding` | | Last Man Standing | `lastManStanding` |
| Soul Wars Zeal | `soulWarsZeal` | | Soul Wars Zeal | `soulWarsZeal` |
| Rifts Closed | `riftsClosed` |
### Leagues ### Leagues
@@ -148,7 +149,9 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
| Kreearra | `kreeArra` | | Kreearra | `kreeArra` |
| K'ril Tsutsaroth | `krilTsutsaroth` | | K'ril Tsutsaroth | `krilTsutsaroth` |
| Mimic | `mimic` | | Mimic | `mimic` |
| Nex | `nex` |
| The Nightmare of Ashihama | `nightmare` | | The Nightmare of Ashihama | `nightmare` |
| Phosani's Nightmare | `phosanisNightmare` |
| Obor | `obor` | | Obor | `obor` |
| Sarachnis | `sarachnis` | | Sarachnis | `sarachnis` |
| Scorpia | `scorpia` | | Scorpia | `scorpia` |
@@ -191,6 +194,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
bountyHunter: {}, bountyHunter: {},
lastManStanding: {}, lastManStanding: {},
soulWarsZeal: {}, soulWarsZeal: {},
riftsClosed: {},
bosses: {} bosses: {}
} }
} }

View File

@@ -11,7 +11,8 @@ import {
getPlayerTableURL, getPlayerTableURL,
getSkillPageURL, getSkillPageURL,
getStatsURL, getStatsURL,
BOSSES BOSSES,
INVALID_FORMAT_ERROR
} from '../src/index'; } from '../src/index';
const B0ATY_NAME = 'B0ATY'; const B0ATY_NAME = 'B0ATY';
@@ -87,6 +88,7 @@ test('Parse CSV to json', () => {
1,6143 1,6143
4814,898 4814,898
37,225 37,225
23,467
382,2780 382,2780
944,3000 944,3000
1981,1452 1981,1452
@@ -114,7 +116,9 @@ test('Parse CSV to json', () => {
625,2391 625,2391
120,2981 120,2981
1,109 1,109
99,39002
3,22666 3,22666
2,84
26,323 26,323
201,1101 201,1101
82,3404 82,3404
@@ -168,6 +172,7 @@ test('Parse CSV to json', () => {
}, },
lastManStanding: { rank: 4814, score: 898 }, lastManStanding: { rank: 4814, score: 898 },
soulWarsZeal: { rank: 37, score: 225 }, soulWarsZeal: { rank: 37, score: 225 },
riftsClosed: { rank: 23, score: 467 },
clues: { clues: {
all: { rank: 32, score: 12148 }, all: { rank: 32, score: 12148 },
beginner: { rank: 3105, score: 76 }, beginner: { rank: 3105, score: 76 },
@@ -205,7 +210,9 @@ test('Parse CSV to json', () => {
kreeArra: { rank: 625, score: 2391 }, kreeArra: { rank: 625, score: 2391 },
krilTsutsaroth: { rank: 120, score: 2981 }, krilTsutsaroth: { rank: 120, score: 2981 },
mimic: { rank: 1, score: 109 }, mimic: { rank: 1, score: 109 },
nex: { rank: 99, score: 39002 },
nightmare: { rank: 3, score: 22666 }, nightmare: { rank: 3, score: 22666 },
phosanisNightmare: { rank: 2, score: 84 },
obor: { rank: 26, score: 323 }, obor: { rank: 26, score: 323 },
sarachnis: { rank: 201, score: 1101 }, sarachnis: { rank: 201, score: 1101 },
scorpia: { rank: 82, score: 3404 }, scorpia: { rank: 82, score: 3404 },
@@ -230,6 +237,18 @@ test('Parse CSV to json', () => {
expect(parseStats(csv)).toStrictEqual(expectedOutput); expect(parseStats(csv)).toStrictEqual(expectedOutput);
}); });
test('Parse CSV with unknown activity', () => {
const statsWithUnknownActivity = `${lynxTitanStats}
-1,-1`;
expect(() => parseStats(statsWithUnknownActivity)).toThrow(
INVALID_FORMAT_ERROR
);
});
test('Parse invalid CSV', () => {
expect(() => parseStats('invalid')).toThrow(INVALID_FORMAT_ERROR);
});
describe('Get name format', () => { describe('Get name format', () => {
it('gets a name with a space', async () => { it('gets a name with a space', async () => {
const data = await getRSNFormat(LYNX_TITAN_SPACE_NAME); const data = await getRSNFormat(LYNX_TITAN_SPACE_NAME);
@@ -442,8 +461,10 @@ test('Get non-existent player', async () => {
}); });
test('Get stats by gamemode', async () => { test('Get stats by gamemode', async () => {
const { skills, bosses } = await getStatsByGamemode(LYNX_TITAN_FORMATTED_NAME); const { skills, bosses } = await getStatsByGamemode(
LYNX_TITAN_FORMATTED_NAME
);
expect(skills).toMatchObject({ expect(skills).toMatchObject({
overall: { rank: expect.any(Number), level: 2277, xp: 4600000000 }, overall: { rank: expect.any(Number), level: 2277, xp: 4600000000 },
attack: { rank: expect.any(Number), level: 99, xp: 200000000 }, attack: { rank: expect.any(Number), level: 99, xp: 200000000 },

View File

@@ -29,6 +29,7 @@
-1,-1 -1,-1
-1,-1 -1,-1
-1,-1 -1,-1
-1,-1
347584,22 347584,22
-1,-1 -1,-1
-1,-1 -1,-1
@@ -79,4 +80,6 @@
-1,-1 -1,-1
-1,-1 -1,-1
-1,-1 -1,-1
-1,-1
-1,-1
-1,-1 -1,-1
Can't render this file because it has a wrong number of fields in line 25.

View File

@@ -1,6 +1,6 @@
{ {
"name": "osrs-json-hiscores", "name": "osrs-json-hiscores",
"version": "2.5.2", "version": "2.7.0",
"description": "The Old School Runescape API wrapper that does more!", "description": "The Old School Runescape API wrapper that does more!",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -27,7 +27,9 @@ import {
rsnFromElement, rsnFromElement,
getActivityPageURL, getActivityPageURL,
httpGet, httpGet,
BOSSES BOSSES,
INVALID_FORMAT_ERROR,
EXTRA_ACTIVITY_COUNT
} from './utils'; } from './utils';
/** /**
@@ -74,6 +76,17 @@ export function parseStats(csv: string): Stats {
.filter((entry) => !!entry) .filter((entry) => !!entry)
.map((stat) => stat.split(',')); .map((stat) => stat.split(','));
if (
splitCSV.length !==
SKILLS.length +
BH_MODES.length +
CLUES.length +
BOSSES.length +
EXTRA_ACTIVITY_COUNT
) {
throw Error(INVALID_FORMAT_ERROR);
}
const skillObjects: Skill[] = splitCSV const skillObjects: Skill[] = splitCSV
.filter((stat) => stat.length === 3) .filter((stat) => stat.length === 3)
.map((stat) => { .map((stat) => {
@@ -100,7 +113,10 @@ export function parseStats(csv: string): Stats {
const [leaguePoints] = activityObjects.splice(0, 1); const [leaguePoints] = activityObjects.splice(0, 1);
const bhObjects = activityObjects.splice(0, BH_MODES.length); const bhObjects = activityObjects.splice(0, BH_MODES.length);
const clueObjects = activityObjects.splice(0, CLUES.length); const clueObjects = activityObjects.splice(0, CLUES.length);
const [lastManStanding, soulWarsZeal] = activityObjects.splice(0, 2); const [lastManStanding, soulWarsZeal, riftsClosed] = activityObjects.splice(
0,
3
);
const bossObjects = activityObjects.splice(0, BOSSES.length); const bossObjects = activityObjects.splice(0, BOSSES.length);
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => { const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
@@ -133,6 +149,7 @@ export function parseStats(csv: string): Stats {
bountyHunter, bountyHunter,
lastManStanding, lastManStanding,
soulWarsZeal, soulWarsZeal,
riftsClosed,
clues, clues,
bosses bosses
}; };

View File

@@ -89,7 +89,9 @@ export type Boss =
| 'kreeArra' | 'kreeArra'
| 'krilTsutsaroth' | 'krilTsutsaroth'
| 'mimic' | 'mimic'
| 'nex'
| 'nightmare' | 'nightmare'
| 'phosanisNightmare'
| 'obor' | 'obor'
| 'sarachnis' | 'sarachnis'
| 'scorpia' | 'scorpia'
@@ -117,6 +119,7 @@ export type ActivityName =
| 'rogueBH' | 'rogueBH'
| 'lastManStanding' | 'lastManStanding'
| 'soulWarsZeal' | 'soulWarsZeal'
| 'riftsClosed'
| 'allClues' | 'allClues'
| 'beginnerClues' | 'beginnerClues'
| 'easyClues' | 'easyClues'
@@ -133,6 +136,7 @@ export interface Stats {
bountyHunter: BH; bountyHunter: BH;
lastManStanding: Activity; lastManStanding: Activity;
soulWarsZeal: Activity; soulWarsZeal: Activity;
riftsClosed: Activity;
bosses: Bosses; bosses: Bosses;
} }
export type Modes = { [M in Gamemode]?: Stats }; export type Modes = { [M in Gamemode]?: Stats };

View File

@@ -97,7 +97,9 @@ export const BOSSES: Boss[] = [
'kreeArra', 'kreeArra',
'krilTsutsaroth', 'krilTsutsaroth',
'mimic', 'mimic',
'nex',
'nightmare', 'nightmare',
'phosanisNightmare',
'obor', 'obor',
'sarachnis', 'sarachnis',
'scorpia', 'scorpia',
@@ -130,6 +132,7 @@ export const ACTIVITIES: ActivityName[] = [
'masterClues', 'masterClues',
'lastManStanding', 'lastManStanding',
'soulWarsZeal', 'soulWarsZeal',
'riftsClosed',
...BOSSES ...BOSSES
]; ];
@@ -165,7 +168,9 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
kreeArra: "Kree'Arra", kreeArra: "Kree'Arra",
krilTsutsaroth: "K'ril Tsutsaroth", krilTsutsaroth: "K'ril Tsutsaroth",
mimic: 'Mimic', mimic: 'Mimic',
nex: 'Nex',
nightmare: 'The Nightmare of Ashihama', nightmare: 'The Nightmare of Ashihama',
phosanisNightmare: "Phosani's Nightmare",
obor: 'Obor', obor: 'Obor',
sarachnis: 'Sarachnis', sarachnis: 'Sarachnis',
scorpia: 'Scorpia', scorpia: 'Scorpia',
@@ -243,3 +248,11 @@ export const FORMATTED_BH_NAMES: FormattedBHNames = {
export const FORMATTED_LMS = 'Last Man Standing'; export const FORMATTED_LMS = 'Last Man Standing';
export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal'; export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
export const FORMATTED_LEAGUE_POINTS = 'League Points'; export const FORMATTED_LEAGUE_POINTS = 'League Points';
export const FORMATTED_RIFTS_CLOSED = 'Rifts Closed';
/**
* Count of activities not including bosses, bounty hunter, or clues.
*/
export const EXTRA_ACTIVITY_COUNT = 4;
export const INVALID_FORMAT_ERROR = 'Invalid hiscores format';

View File

@@ -1108,11 +1108,11 @@ axe-core@^4.0.2:
integrity sha512-vwPpH4Aj4122EW38mxO/fxhGKtwWTMLDIJfZ1He0Edbtjcfna/R3YB67yVhezUMzqc3Jr3+Ii50KRntlENL4xQ== integrity sha512-vwPpH4Aj4122EW38mxO/fxhGKtwWTMLDIJfZ1He0Edbtjcfna/R3YB67yVhezUMzqc3Jr3+Ii50KRntlENL4xQ==
axios@^0.21.1: axios@^0.21.1:
version "0.21.1" version "0.21.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017"
integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==
dependencies: dependencies:
follow-redirects "^1.10.0" follow-redirects "^1.14.0"
axobject-query@^2.2.0: axobject-query@^2.2.0:
version "2.2.0" version "2.2.0"
@@ -2459,10 +2459,10 @@ flatted@^3.1.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469" resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469"
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==
follow-redirects@^1.10.0: follow-redirects@^1.14.0:
version "1.13.1" version "1.14.8"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg== integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
for-in@^1.0.2: for-in@^1.0.2:
version "1.0.2" version "1.0.2"
@@ -4837,9 +4837,9 @@ path-key@^3.0.0, path-key@^3.1.0:
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
path-parse@^1.0.6: path-parse@^1.0.6:
version "1.0.6" version "1.0.7"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
path-type@^2.0.0: path-type@^2.0.0:
version "2.0.0" version "2.0.0"
@@ -5892,9 +5892,9 @@ tmp@^0.0.33:
os-tmpdir "~1.0.2" os-tmpdir "~1.0.2"
tmpl@1.0.x: tmpl@1.0.x:
version "1.0.4" version "1.0.5"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc"
integrity sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE= integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==
to-fast-properties@^2.0.0: to-fast-properties@^2.0.0:
version "2.0.0" version "2.0.0"