blob: 090d47010ff3c040a208c0da246aa35f0cac8f9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/**
* @author Titus Wormer
* @copyright 2016 Titus Wormer
* @license MIT
* @module is-alphabetical
* @fileoverview Check if a character is alphabetical.
*/
'use strict';
/* eslint-env commonjs */
/* Expose. */
module.exports = alphabetical;
/**
* Check whether the given character code, or the character
* code at the first character, is alphabetical.
*
* @param {string|number} character
* @return {boolean} - Whether `character` is alphabetical.
*/
function alphabetical(character) {
var code = typeof character === 'string' ?
character.charCodeAt(0) : character;
return (code >= 97 && code <= 122) || /* a-z */
(code >= 65 && code <= 90); /* A-Z */
}
|