-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added getTeamByName & getEventByName (#401)
* added getTeamByName * Delete package-lock.json * Update package.json * Update README.md added getTeamByName function * added getEventByName * Update README.md * Update README.md * Update README.md * Update index.ts fixed typo
- Loading branch information
Showing
5 changed files
with
4,027 additions
and
3,734 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { HLTVConfig } from '../config' | ||
import { FullEvent } from '../models/FullEvent' | ||
import HLTV from '../index' | ||
|
||
export const getEventByName = (config: HLTVConfig) => async ({ | ||
name | ||
}: { | ||
name: string | ||
}): Promise<FullEvent> => { | ||
const pageContent = JSON.parse( | ||
await config.loadPage!(`${config.hltvUrl}/search?term=${name}`) | ||
) | ||
const firstResult = pageContent[0].events[0] | ||
|
||
if (!firstResult) { | ||
throw new Error(`Event ${name} not found`) | ||
} | ||
|
||
return HLTV.getEvent({ id: firstResult.id }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { HLTVConfig } from '../config' | ||
import { FullTeam } from '../models/FullTeam' | ||
import HLTV from '../index' | ||
|
||
export const getTeamByName = (config: HLTVConfig) => async ({ | ||
name | ||
}: { | ||
name: string | ||
}): Promise<FullTeam> => { | ||
const pageContent = JSON.parse( | ||
await config.loadPage!(`${config.hltvUrl}/search?term=${name}`) | ||
) | ||
const firstResult = pageContent[0].teams[0] | ||
|
||
if (!firstResult) { | ||
throw new Error(`Team ${name} not found`) | ||
} | ||
|
||
return HLTV.getTeam({ id: firstResult.id }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.