Add .nonEmptyStringAndNotWhitespace() (#161)

Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
This commit is contained in:
Ivan Katliarchuk 2022-02-25 09:10:57 +00:00 committed by GitHub
parent 04ccf21dba
commit 23cf074a73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 0 deletions

View file

@ -245,6 +245,17 @@ Returns `true` if the value is a `string` and the `.length` is 0.
Returns `true` if the value is a `string` and the `.length` is more than 0.
##### .nonEmptyStringAndNotWhitespace(value)
Returns `true` if the value is a `string` that is not empty and not whitespace.
```js
const values = ['property1', '', null, 'property2', ' ', undefined];
values.filter(is.nonEmptyStringAndNotWhitespace);
//=> ['property1', 'property2']
```
##### .emptyStringOrWhitespace(value)
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.