mirror of
				https://github.com/maxswa/osrs-json-hiscores.git
				synced 2025-10-15 10:19:04 +00:00 
			
		
		
		
	Compare commits
	
		
			11 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 0bf491638c | ||
|   | febca534b0 | ||
|   | 8daee5c39b | ||
|   | f98cf8aaaa | ||
|   | 5d9f6a6bac | ||
|   | 8737b50a82 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 1255e7e3d2 | ||
|   | f4135d0b0f | ||
|   | 6135ff459c | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 9fb7e4cebc | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 11350b2444 | 
| @@ -148,6 +148,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses | ||||
| | Kreearra                          |           `kreeArra`           | | ||||
| | K'ril Tsutsaroth                  |        `krilTsutsaroth`        | | ||||
| | Mimic                             |            `mimic`             | | ||||
| | Nex                               |             `nex`              | | ||||
| | The Nightmare of Ashihama         |          `nightmare`           | | ||||
| | Phosani's Nightmare               |      `phosanisNightmare`       | | ||||
| | Obor                              |             `obor`             | | ||||
|   | ||||
| @@ -11,7 +11,8 @@ import { | ||||
|   getPlayerTableURL, | ||||
|   getSkillPageURL, | ||||
|   getStatsURL, | ||||
|   BOSSES | ||||
|   BOSSES, | ||||
|   INVALID_FORMAT_ERROR | ||||
| } from '../src/index'; | ||||
|  | ||||
| const B0ATY_NAME = 'B0ATY'; | ||||
| @@ -114,6 +115,7 @@ test('Parse CSV to json', () => { | ||||
|   625,2391 | ||||
|   120,2981 | ||||
|   1,109 | ||||
|   99,39002 | ||||
|   3,22666 | ||||
|   2,84 | ||||
|   26,323 | ||||
| @@ -206,6 +208,7 @@ test('Parse CSV to json', () => { | ||||
|       kreeArra: { rank: 625, score: 2391 }, | ||||
|       krilTsutsaroth: { rank: 120, score: 2981 }, | ||||
|       mimic: { rank: 1, score: 109 }, | ||||
|       nex: { rank: 99, score: 39002 }, | ||||
|       nightmare: { rank: 3, score: 22666 }, | ||||
|       phosanisNightmare: { rank: 2, score: 84 }, | ||||
|       obor: { rank: 26, score: 323 }, | ||||
| @@ -232,6 +235,16 @@ test('Parse CSV to json', () => { | ||||
|   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', () => { | ||||
|   it('gets a name with a space', async () => { | ||||
|     const data = await getRSNFormat(LYNX_TITAN_SPACE_NAME); | ||||
| @@ -444,7 +457,9 @@ test('Get non-existent player', 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({ | ||||
|     overall: { rank: expect.any(Number), level: 2277, xp: 4600000000 }, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "osrs-json-hiscores", | ||||
|   "version": "2.6.0", | ||||
|   "version": "2.7.0", | ||||
|   "description": "The Old School Runescape API wrapper that does more!", | ||||
|   "main": "lib/index.js", | ||||
|   "types": "lib/index.d.ts", | ||||
|   | ||||
| @@ -27,7 +27,8 @@ import { | ||||
|   rsnFromElement, | ||||
|   getActivityPageURL, | ||||
|   httpGet, | ||||
|   BOSSES | ||||
|   BOSSES, | ||||
|   INVALID_FORMAT_ERROR | ||||
| } from './utils'; | ||||
|  | ||||
| /** | ||||
| @@ -74,6 +75,10 @@ export function parseStats(csv: string): Stats { | ||||
|     .filter((entry) => !!entry) | ||||
|     .map((stat) => stat.split(',')); | ||||
|  | ||||
|   if (splitCSV.length !== SKILLS.length + BH_MODES.length + CLUES.length + BOSSES.length + 3) { | ||||
|     throw Error(INVALID_FORMAT_ERROR); | ||||
|   } | ||||
|  | ||||
|   const skillObjects: Skill[] = splitCSV | ||||
|     .filter((stat) => stat.length === 3) | ||||
|     .map((stat) => { | ||||
|   | ||||
| @@ -89,6 +89,7 @@ export type Boss = | ||||
|   | 'kreeArra' | ||||
|   | 'krilTsutsaroth' | ||||
|   | 'mimic' | ||||
|   | 'nex' | ||||
|   | 'nightmare' | ||||
|   | 'phosanisNightmare' | ||||
|   | 'obor' | ||||
|   | ||||
| @@ -97,6 +97,7 @@ export const BOSSES: Boss[] = [ | ||||
|   'kreeArra', | ||||
|   'krilTsutsaroth', | ||||
|   'mimic', | ||||
|   'nex', | ||||
|   'nightmare', | ||||
|   'phosanisNightmare', | ||||
|   'obor', | ||||
| @@ -166,6 +167,7 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = { | ||||
|   kreeArra: "Kree'Arra", | ||||
|   krilTsutsaroth: "K'ril Tsutsaroth", | ||||
|   mimic: 'Mimic', | ||||
|   nex: 'Nex', | ||||
|   nightmare: 'The Nightmare of Ashihama', | ||||
|   phosanisNightmare: "Phosani's Nightmare", | ||||
|   obor: 'Obor', | ||||
| @@ -245,3 +247,5 @@ export const FORMATTED_BH_NAMES: FormattedBHNames = { | ||||
| export const FORMATTED_LMS = 'Last Man Standing'; | ||||
| export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal'; | ||||
| export const FORMATTED_LEAGUE_POINTS = 'League Points'; | ||||
|  | ||||
| export const INVALID_FORMAT_ERROR = 'Invalid hiscores format'; | ||||
|   | ||||
							
								
								
									
										28
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								yarn.lock
									
									
									
									
									
								
							| @@ -1108,11 +1108,11 @@ axe-core@^4.0.2: | ||||
|   integrity sha512-vwPpH4Aj4122EW38mxO/fxhGKtwWTMLDIJfZ1He0Edbtjcfna/R3YB67yVhezUMzqc3Jr3+Ii50KRntlENL4xQ== | ||||
|  | ||||
| axios@^0.21.1: | ||||
|   version "0.21.1" | ||||
|   resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" | ||||
|   integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== | ||||
|   version "0.21.2" | ||||
|   resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017" | ||||
|   integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg== | ||||
|   dependencies: | ||||
|     follow-redirects "^1.10.0" | ||||
|     follow-redirects "^1.14.0" | ||||
|  | ||||
| axobject-query@^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" | ||||
|   integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== | ||||
|  | ||||
| follow-redirects@^1.10.0: | ||||
|   version "1.13.1" | ||||
|   resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7" | ||||
|   integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg== | ||||
| follow-redirects@^1.14.0: | ||||
|   version "1.14.4" | ||||
|   resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" | ||||
|   integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g== | ||||
|  | ||||
| for-in@^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== | ||||
|  | ||||
| path-parse@^1.0.6: | ||||
|   version "1.0.6" | ||||
|   resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" | ||||
|   integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== | ||||
|   version "1.0.7" | ||||
|   resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" | ||||
|   integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== | ||||
|  | ||||
| path-type@^2.0.0: | ||||
|   version "2.0.0" | ||||
| @@ -5892,9 +5892,9 @@ tmp@^0.0.33: | ||||
|     os-tmpdir "~1.0.2" | ||||
|  | ||||
| tmpl@1.0.x: | ||||
|   version "1.0.4" | ||||
|   resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" | ||||
|   integrity sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE= | ||||
|   version "1.0.5" | ||||
|   resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" | ||||
|   integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw== | ||||
|  | ||||
| to-fast-properties@^2.0.0: | ||||
|   version "2.0.0" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user