UNPKG

awesome-string

Version:

The ultimate JavaScript string library

25 lines (24 loc) 632 B
import coerceToString from 'helper/string/coerce_to_string'; /** * 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 * as.isBlank(''); * // => true * * as.isBlank(' '); * // => true * * as.isBlank('World'); * // => false */ export default function isBlank(subject) { const subjectString = coerceToString(subject); return subjectString.trim().length === 0; }