mirror of
				https://github.com/maxswa/osrs-json-hiscores.git
				synced 2025-10-15 10:19:04 +00:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 6d000df717 | ||
|   | 5575a83039 | ||
|   | 86d9bcb2e7 | ||
|   | 79c067152c | ||
|   | e51e7bc32e | ||
|   | 7d7c7f9b08 | 
| @@ -179,6 +179,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses | |||||||
| | Vetion                            |            `vetion`            | | | Vetion                            |            `vetion`            | | ||||||
| | Vorkath                           |           `vorkath`            | | | Vorkath                           |           `vorkath`            | | ||||||
| | Wintertodt                        |          `wintertodt`          | | | Wintertodt                        |          `wintertodt`          | | ||||||
|  | | Yama                              |             `yama`             | | ||||||
| | Zalcano                           |           `zalcano`            | | | Zalcano                           |           `zalcano`            | | ||||||
| | Zulrah                            |            `zulrah`            | | | Zulrah                            |            `zulrah`            | | ||||||
|  |  | ||||||
|   | |||||||
| @@ -104,5 +104,6 @@ | |||||||
| 97368,51 | 97368,51 | ||||||
| 15591,2780 | 15591,2780 | ||||||
| 1000405,67 | 1000405,67 | ||||||
|  | 19722,173 | ||||||
| 213696,25 | 213696,25 | ||||||
| 240082,340 | 240082,340 | ||||||
| Can't render this file because it has a wrong number of fields in line 25. | 
| @@ -664,12 +664,18 @@ | |||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|       "id": 82, |       "id": 82, | ||||||
|  |       "name": "Yama", | ||||||
|  |       "rank": 19722, | ||||||
|  |       "score": 173 | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "id": 83, | ||||||
|       "name": "Zalcano", |       "name": "Zalcano", | ||||||
|       "rank": 213696, |       "rank": 213696, | ||||||
|       "score": 25 |       "score": 25 | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|       "id": 83, |       "id": 84, | ||||||
|       "name": "Zulrah", |       "name": "Zulrah", | ||||||
|       "rank": 240082, |       "rank": 240082, | ||||||
|       "score": 340 |       "score": 340 | ||||||
|   | |||||||
| @@ -15,7 +15,10 @@ import { | |||||||
|   InvalidFormatError, |   InvalidFormatError, | ||||||
|   BH_MODES, |   BH_MODES, | ||||||
|   parseJsonStats, |   parseJsonStats, | ||||||
|   HiscoresResponse |   HiscoresResponse, | ||||||
|  |   InvalidRSNError, | ||||||
|  |   PlayerNotFoundError, | ||||||
|  |   HiScoresError | ||||||
| } from '../src/index'; | } from '../src/index'; | ||||||
|  |  | ||||||
| const B0ATY_NAME = 'B0ATY'; | const B0ATY_NAME = 'B0ATY'; | ||||||
| @@ -24,6 +27,8 @@ const LYNX_TITAN_SPACE_NAME = 'lYnX tiTaN'; | |||||||
| const LYNX_TITAN_UNDERSCORE_NAME = 'lYnX_tiTaN'; | const LYNX_TITAN_UNDERSCORE_NAME = 'lYnX_tiTaN'; | ||||||
| const LYNX_TITAN_HYPHEN_NAME = 'lYnX-tiTaN'; | const LYNX_TITAN_HYPHEN_NAME = 'lYnX-tiTaN'; | ||||||
| const LYNX_TITAN_FORMATTED_NAME = 'Lynx Titan'; | const LYNX_TITAN_FORMATTED_NAME = 'Lynx Titan'; | ||||||
|  | const NON_EXISTENT_NAME = 'nonExistent'; | ||||||
|  | const ERROR_NAME = 'errorName'; | ||||||
|  |  | ||||||
| const attackTopPage = readFileSync(`${__dirname}/attackTopPage.html`, 'utf8'); | const attackTopPage = readFileSync(`${__dirname}/attackTopPage.html`, 'utf8'); | ||||||
| const b0atyNamePage = readFileSync(`${__dirname}/b0atyNamePage.html`, 'utf8'); | const b0atyNamePage = readFileSync(`${__dirname}/b0atyNamePage.html`, 'utf8'); | ||||||
| @@ -57,6 +62,12 @@ jest.spyOn(axios, 'get').mockImplementation((url) => { | |||||||
|   if (getStatsURL('main', LYNX_TITAN_FORMATTED_NAME, true) === url) { |   if (getStatsURL('main', LYNX_TITAN_FORMATTED_NAME, true) === url) { | ||||||
|     return Promise.resolve({ status: 200, data: lynxTitanStats }); |     return Promise.resolve({ status: 200, data: lynxTitanStats }); | ||||||
|   } |   } | ||||||
|  |   if (getPlayerTableURL('main', NON_EXISTENT_NAME) === url) { | ||||||
|  |     return Promise.resolve({ data: '<html></html>' }); | ||||||
|  |   } | ||||||
|  |   if (getPlayerTableURL('main', ERROR_NAME)) { | ||||||
|  |     return Promise.reject(); | ||||||
|  |   } | ||||||
|   throw new Error(`No mock response for URL: ${url}`); |   throw new Error(`No mock response for URL: ${url}`); | ||||||
| }); | }); | ||||||
|  |  | ||||||
| @@ -167,6 +178,7 @@ test('Parse CSV to json', () => { | |||||||
|   1940,272 |   1940,272 | ||||||
|   8623,1340 |   8623,1340 | ||||||
|   605,1694 |   605,1694 | ||||||
|  |   15233,245 | ||||||
|   -1,-1 |   -1,-1 | ||||||
|   3867,4583`; |   3867,4583`; | ||||||
|  |  | ||||||
| @@ -284,6 +296,7 @@ test('Parse CSV to json', () => { | |||||||
|       vetion: { rank: 1940, score: 272 }, |       vetion: { rank: 1940, score: 272 }, | ||||||
|       vorkath: { rank: 8623, score: 1340 }, |       vorkath: { rank: 8623, score: 1340 }, | ||||||
|       wintertodt: { rank: 605, score: 1694 }, |       wintertodt: { rank: 605, score: 1694 }, | ||||||
|  |       yama: { rank: 15233, score: 245 }, | ||||||
|       zalcano: { rank: -1, score: -1 }, |       zalcano: { rank: -1, score: -1 }, | ||||||
|       zulrah: { rank: 3867, score: 4583 } |       zulrah: { rank: 3867, score: 4583 } | ||||||
|     } |     } | ||||||
| @@ -322,7 +335,15 @@ describe('Get name format', () => { | |||||||
|     expect(data).toBe(B0ATY_FORMATTED_NAME); |     expect(data).toBe(B0ATY_FORMATTED_NAME); | ||||||
|   }); |   }); | ||||||
|   it('throws an error for a name with invalid characters', async () => { |   it('throws an error for a name with invalid characters', async () => { | ||||||
|     await expect(getRSNFormat('b&aty')).rejects.toBeTruthy(); |     await expect(getRSNFormat('b&aty')).rejects.toThrow(InvalidRSNError); | ||||||
|  |   }); | ||||||
|  |   it('throws an error for a non-existent player', async () => { | ||||||
|  |     await expect(getRSNFormat(NON_EXISTENT_NAME)).rejects.toThrow( | ||||||
|  |       PlayerNotFoundError | ||||||
|  |     ); | ||||||
|  |   }); | ||||||
|  |   it('throws an error for a hiscores issue', async () => { | ||||||
|  |     await expect(getRSNFormat(ERROR_NAME)).rejects.toThrow(HiScoresError); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
| @@ -509,7 +530,7 @@ test('Get attack top page', async () => { | |||||||
|  |  | ||||||
| test('Get non-existent player', async () => { | test('Get non-existent player', async () => { | ||||||
|   getStats('fishy').catch((err) => { |   getStats('fishy').catch((err) => { | ||||||
|     if (err.response) { |     if (err?.response) { | ||||||
|       expect(err.response.status).toBe(404); |       expect(err.response.status).toBe(404); | ||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "osrs-json-hiscores", |   "name": "osrs-json-hiscores", | ||||||
|   "version": "2.21.0", |   "version": "2.22.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", | ||||||
|   | |||||||
| @@ -86,11 +86,12 @@ export async function getOfficialStats( | |||||||
|  */ |  */ | ||||||
| export async function getRSNFormat( | export async function getRSNFormat( | ||||||
|   rsn: string, |   rsn: string, | ||||||
|   config?: AxiosRequestConfig |   config?: AxiosRequestConfig, | ||||||
|  |   mode: Gamemode = 'main' | ||||||
| ): Promise<string> { | ): Promise<string> { | ||||||
|   validateRSN(rsn); |   validateRSN(rsn); | ||||||
|  |  | ||||||
|   const url = getPlayerTableURL('main', rsn); |   const url = getPlayerTableURL(mode, rsn); | ||||||
|   try { |   try { | ||||||
|     const response = await httpGet<string | Buffer | BinaryData | undefined>( |     const response = await httpGet<string | Buffer | BinaryData | undefined>( | ||||||
|       url, |       url, | ||||||
| @@ -103,10 +104,10 @@ export async function getRSNFormat( | |||||||
|     if (anchor) { |     if (anchor) { | ||||||
|       return rsnFromElement(anchor); |       return rsnFromElement(anchor); | ||||||
|     } |     } | ||||||
|     throw new PlayerNotFoundError(); |  | ||||||
|   } catch { |   } catch { | ||||||
|     throw new HiScoresError(); |     throw new HiScoresError(); | ||||||
|   } |   } | ||||||
|  |   throw new PlayerNotFoundError(); | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
| @@ -130,6 +130,7 @@ export type Boss = | |||||||
|   | 'vetion' |   | 'vetion' | ||||||
|   | 'vorkath' |   | 'vorkath' | ||||||
|   | 'wintertodt' |   | 'wintertodt' | ||||||
|  |   | 'yama' | ||||||
|   | 'zalcano' |   | 'zalcano' | ||||||
|   | 'zulrah'; |   | 'zulrah'; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -137,6 +137,7 @@ export const BOSSES: Boss[] = [ | |||||||
|   'vetion', |   'vetion', | ||||||
|   'vorkath', |   'vorkath', | ||||||
|   'wintertodt', |   'wintertodt', | ||||||
|  |   'yama', | ||||||
|   'zalcano', |   'zalcano', | ||||||
|   'zulrah' |   'zulrah' | ||||||
| ]; | ]; | ||||||
| @@ -231,6 +232,7 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = { | |||||||
|   vetion: "Vet'ion", |   vetion: "Vet'ion", | ||||||
|   vorkath: 'Vorkath', |   vorkath: 'Vorkath', | ||||||
|   wintertodt: 'Wintertodt', |   wintertodt: 'Wintertodt', | ||||||
|  |   yama: 'Yama', | ||||||
|   zalcano: 'Zalcano', |   zalcano: 'Zalcano', | ||||||
|   zulrah: 'Zulrah' |   zulrah: 'Zulrah' | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user