mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-09-24 15:00:31 +08:00
21 lines
505 B
TypeScript
21 lines
505 B
TypeScript
const formatter = Intl.NumberFormat('en-US', {
|
|
notation: 'compact',
|
|
});
|
|
|
|
export async function countStars(
|
|
repo = 'kamranahmedse/developer-roadmap'
|
|
): Promise<number> {
|
|
const repoData = await fetch(`https://api.github.com/repos/${repo}`);
|
|
const json = await repoData.json();
|
|
|
|
return json.stargazers_count * 1;
|
|
}
|
|
|
|
export async function getFormattedStars(
|
|
repo = 'kamranahmedse/developer-roadmap'
|
|
): Promise<string> {
|
|
const stars = await countStars(repo);
|
|
|
|
return formatter.format(stars);
|
|
}
|