Travis build: 1342
This commit is contained in:
32
README.md
32
README.md
@ -340,6 +340,7 @@ average(1, 2, 3);
|
||||
* [`is`](#is)
|
||||
* [`isArrayLike`](#isarraylike)
|
||||
* [`isBoolean`](#isboolean)
|
||||
* [`isEmpty`](#isempty)
|
||||
* [`isFunction`](#isfunction)
|
||||
* [`isNil`](#isnil)
|
||||
* [`isNull`](#isnull)
|
||||
@ -5629,6 +5630,37 @@ isBoolean(false); // true
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### isEmpty
|
||||
|
||||
Returns true if the a value is an empty object, collection, map or set, has no enumerable properties or is any type that is not considered a collection.
|
||||
|
||||
Check if the provided value is `null` or if its `length` is equal to `0`.
|
||||
|
||||
```js
|
||||
const isEmpty = val => val == null || !(Object.keys(val) || val).length;
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
isEmpty(new Map()); // true
|
||||
isEmpty(new Set()); // true
|
||||
isEmpty([]); // true
|
||||
isEmpty({}); // true
|
||||
isEmpty(''); // true
|
||||
isEmpty([1, 2]); // false
|
||||
isEmpty({ a: 1, b: 2 }); // false
|
||||
isEmpty('text'); // false
|
||||
isEmpty(123); // true - type is not considered a collection
|
||||
isEmpty(true); // true - type is not considered a collection
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### isFunction
|
||||
|
||||
Checks if the given argument is a function.
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user