Roadmap to becoming a developer in 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
558 B

2 years ago
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> {
if (import.meta.env.DEV) {
return '223k';
}
2 years ago
const stars = await countStars(repo);
return formatter.format(stars);
}