diff options
Diffstat (limited to 'tools/eslint/node_modules/is-hexadecimal/index.js')
-rw-r--r-- | tools/eslint/node_modules/is-hexadecimal/index.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/is-hexadecimal/index.js b/tools/eslint/node_modules/is-hexadecimal/index.js new file mode 100644 index 0000000000..dfb9ddb578 --- /dev/null +++ b/tools/eslint/node_modules/is-hexadecimal/index.js @@ -0,0 +1,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 */); +} |