kepler-chat/src/lib/utils/is-letter.ts
Aidan Bleser 7b9595e571
Post Hackathon Stuff (#40)
Co-authored-by: Thomas G. Lopes <26071571+TGlide@users.noreply.github.com>
2025-07-10 04:45:02 -07:00

25 lines
466 B
TypeScript

/*
Installed from @ieedan/std
*/
export const LETTER_REGEX = new RegExp(/[a-zA-Z]/);
/** Checks if the provided character is a letter in the alphabet.
*
* @param char
* @returns
*
* ## Usage
* ```ts
* isLetter('a');
* ```
*/
export function isLetter(char: string): boolean {
if (char.length > 1) {
throw new Error(
`You probably only meant to pass a character to this function. Instead you gave ${char}`
);
}
return LETTER_REGEX.test(char);
}