index.js 445 B

12345678910111213141516
  1. /**
  2. * Check if the given character code, or the character code at the first
  3. * character, is alphabetical.
  4. *
  5. * @param {string|number} character
  6. * @returns {boolean} Whether `character` is alphabetical.
  7. */
  8. export function isAlphabetical(character) {
  9. const code =
  10. typeof character === 'string' ? character.charCodeAt(0) : character
  11. return (
  12. (code >= 97 && code <= 122) /* a-z */ ||
  13. (code >= 65 && code <= 90) /* A-Z */
  14. )
  15. }