ember-source
Version:
A JavaScript framework for creating ambitious web applications
37 lines (31 loc) • 828 B
JavaScript
import isEmpty from './is_empty.js';
/**
@module @ember/utils
*/
/**
A value is blank if it is empty or a whitespace string.
```javascript
import { isBlank } from '@ember/utils';
isBlank(null); // true
isBlank(undefined); // true
isBlank(''); // true
isBlank([]); // true
isBlank('\n\t'); // true
isBlank(' '); // true
isBlank({}); // false
isBlank('\n\t Hello'); // false
isBlank('Hello world'); // false
isBlank([1,2,3]); // false
```
@method isBlank
@static
@for @ember/utils
@param {Object} obj Value to test
@return {Boolean}
@since 1.5.0
@public
*/
function isBlank(obj) {
return isEmpty(obj) || typeof obj === 'string' && /\S/.test(obj) === false;
}
export { isBlank as default };