blob: dfb9ddb5780072d3cb11b738193789d67dcfeba1 (
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
30
|
/**
* @author Titus Wormer
* @copyright 2016 Titus Wormer
* @license MIT
* @module is-hexadecimal
* @fileoverview Check if a character is hexadecimal.
*/
'use strict';
/* eslint-env commonjs */
/* Expose. */
module.exports = hexadecimal;
/**
* Check whether the given character code, or the character
* code at the first character, is hexadecimal.
*
* @param {string|number} character
* @return {boolean} - Whether `character` is hexadecimal.
*/
function hexadecimal(character) {
var code = typeof character === 'string' ?
character.charCodeAt(0) : character;
return (code >= 97 /* a */ && code <= 102 /* z */) ||
(code >= 65 /* A */ && code <= 70 /* Z */) ||
(code >= 48 /* A */ && code <= 57 /* Z */);
}
|