UNPKG

voca

Version:

The ultimate JavaScript string library

33 lines (28 loc) 738 B
'use strict'; require('./internal/is_nil.js'); require('./is_string.js'); var coerce_to_string = require('./internal/coerce_to_string.js'); /** * Checks whether `subject` is empty or contains only whitespaces. * * @function isBlank * @static * @since 1.0.0 * @memberOf Query * @param {string} [subject=''] The string to verify. * @return {boolean} Returns `true` if `subject` is empty or contains only whitespaces or `false` otherwise. * @example * v.isBlank(''); * // => true * * v.isBlank(' '); * // => true * * v.isBlank('World'); * // => false */ function isBlank(subject) { var subjectString = coerce_to_string.coerceToString(subject); return subjectString.trim().length === 0; } module.exports = isBlank;