Travis build: 1342

This commit is contained in:
30secondsofcode
2018-01-23 17:28:14 +00:00
parent 2ba8012479
commit e5e0ad6e5f
2 changed files with 44 additions and 1 deletions

View File

@ -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