mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
1 Commits
v2.8.0
...
add-guardi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e77737f422 |
@@ -88,7 +88,7 @@ test('Parse CSV to json', () => {
|
|||||||
1,6143
|
1,6143
|
||||||
4814,898
|
4814,898
|
||||||
37,225
|
37,225
|
||||||
25,1110
|
23,467
|
||||||
382,2780
|
382,2780
|
||||||
944,3000
|
944,3000
|
||||||
1981,1452
|
1981,1452
|
||||||
@@ -172,7 +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: 25, score: 1110 },
|
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 },
|
||||||
@@ -238,9 +238,11 @@ test('Parse CSV to json', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Parse CSV with unknown activity', () => {
|
test('Parse CSV with unknown activity', () => {
|
||||||
const statsWithUnknownActivity = lynxTitanStats + `
|
const statsWithUnknownActivity = `${lynxTitanStats}
|
||||||
-1,-1`;
|
-1,-1`;
|
||||||
expect(() => parseStats(statsWithUnknownActivity)).toThrow(INVALID_FORMAT_ERROR);
|
expect(() => parseStats(statsWithUnknownActivity)).toThrow(
|
||||||
|
INVALID_FORMAT_ERROR
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Parse invalid CSV', () => {
|
test('Parse invalid CSV', () => {
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -82,4 +83,3 @@
|
|||||||
-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.
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "osrs-json-hiscores",
|
"name": "osrs-json-hiscores",
|
||||||
"version": "2.8.0",
|
"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",
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ import {
|
|||||||
getActivityPageURL,
|
getActivityPageURL,
|
||||||
httpGet,
|
httpGet,
|
||||||
BOSSES,
|
BOSSES,
|
||||||
INVALID_FORMAT_ERROR
|
INVALID_FORMAT_ERROR,
|
||||||
|
EXTRA_ACTIVITY_COUNT
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +76,14 @@ 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 + 4) {
|
if (
|
||||||
|
splitCSV.length !==
|
||||||
|
SKILLS.length +
|
||||||
|
BH_MODES.length +
|
||||||
|
CLUES.length +
|
||||||
|
BOSSES.length +
|
||||||
|
EXTRA_ACTIVITY_COUNT
|
||||||
|
) {
|
||||||
throw Error(INVALID_FORMAT_ERROR);
|
throw Error(INVALID_FORMAT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,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, riftsClosed] = activityObjects.splice(0, 3);
|
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) => {
|
||||||
|
|||||||
@@ -250,4 +250,9 @@ 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';
|
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';
|
export const INVALID_FORMAT_ERROR = 'Invalid hiscores format';
|
||||||
|
|||||||
@@ -4295,9 +4295,9 @@ minimist-options@^4.0.2:
|
|||||||
kind-of "^6.0.3"
|
kind-of "^6.0.3"
|
||||||
|
|
||||||
minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
|
minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
|
||||||
version "1.2.6"
|
version "1.2.5"
|
||||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||||
|
|
||||||
mixin-deep@^1.2.0:
|
mixin-deep@^1.2.0:
|
||||||
version "1.3.2"
|
version "1.3.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user