You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
606 B

/**
* @author Titus Wormer
* @copyright 2016 Titus Wormer
* @license MIT
* @module is-decimal
* @fileoverview Check if a character is decimal.
*/
'use strict';
/* eslint-env commonjs */
/* Expose. */
module.exports = decimal;
/**
* Check whether the given character code, or the character
* code at the first character, is decimal.
*
* @param {string|number} character
* @return {boolean} - Whether `character` is decimal.
*/
function decimal(character) {
var code = typeof character === 'string' ?
character.charCodeAt(0) : character;
return code >= 48 && code <= 57; /* 0-9 */
}