did-they-starred-this
v0.0.0
Published
A lightweight, dependency-free Node.js module to efficiently check if a user has starred a specific GitHub repository.
Maintainers
Readme
Did They Star This?
A lightweight, dependency-free module to efficiently check if a user has starred a specific GitHub repository.
It's optimized to minimize GitHub API requests by intelligently choosing whether to iterate through the repository's stargazers or the user's starred repositories, whichever list is smaller.
Features
- Efficient: Minimizes API calls by comparing star counts before iterating.
- No Dependencies: Runs in any environment with
fetch(Node.js, Deno, Browsers). - Simple API: A single asynchronous function to get the job done.
- ESM-first: Delivered via ESM for modern projects.
Usage
No installation needed! You can use it directly via esm.sh.
import { didTheyStarredThis } from 'https://esm.sh/did-they-starred-this'
// Use Your GitHub Personal Access Token (optional, but recommended)
const hasStarred = await didTheyStarredThis('steve02081504/did_they_starred_this', 'steve02081504', process.env.GITHUB_TOKEN)
console.log(`steve02081504 starred did_they_starred_this: ${hasStarred}`)API
didTheyStarredThis(repoFullName, username, [token])
repoFullName{string} Required - The full name of the repository (e.g.,'freeCodeCamp/freeCodeCamp').username{string} Required - The GitHub username to check.token{string} Optional - A GitHub Personal Access Token to increase API rate limits.- Returns:
Promise<boolean>- Resolves totrueif the user has starred the repository, otherwisefalse.
Note on API Rate Limiting: The GitHub API has strict rate limits for unauthenticated requests. For any serious application, providing a Personal Access Token is highly recommended.
