voca
Version:
The ultimate JavaScript string library
32 lines (28 loc) • 748 B
JavaScript
import './internal/is_nil.js';
import './is_string.js';
import { c as coerceToString } from './internal/coerce_to_string.js';
import { l as REGEXP_DIGIT } from './internal/const.js';
/**
* Checks whether `subject` contains only digit characters.
*
* @function isDigit
* @static
* @since 1.0.0
* @memberOf Query
* @param {string} [subject=''] The string to verify.
* @return {boolean} Returns `true` if `subject` contains only digit characters or `false` otherwise.
* @example
* v.isDigit('35');
* // => true
*
* v.isDigit('1.5');
* // => false
*
* v.isDigit('ten');
* // => false
*/
function isDigit(subject) {
var subjectString = coerceToString(subject);
return REGEXP_DIGIT.test(subjectString);
}
export default isDigit;