Travis build: 748 [ci skip]

This commit is contained in:
Travis CI
2017-12-31 17:34:18 +00:00
parent 2782954031
commit 2c31cb1193
2 changed files with 42 additions and 1 deletions

View File

@ -250,6 +250,7 @@
* [`isFunction`](#isfunction)
* [`isNull`](#isnull)
* [`isNumber`](#isnumber)
* [`isPrimitive`](#isprimitive)
* [`isPromiseLike`](#ispromiselike)
* [`isString`](#isstring)
* [`isSymbol`](#issymbol)
@ -4204,6 +4205,37 @@ isNumber(1); // true
<br>[⬆ Back to top](#table-of-contents)
### isPrimitive
Returns a boolean determining if the supplied value is primitive or not.
Use `Array.includes()` on an array of type strings which are not primitive,
supplying the type using `typeof`.
Since `typeof null` evaluates to `'object'`, it needs to be directly compared.
```js
const isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null;
```
<details>
<summary>Examples</summary>
```js
isPrimitive(window.someNonExistentProperty); // true
isPrimitive(null); // true
isPrimitive(50); // true
isPrimitive('Hello!'); // true
isPrimitive(false); // true
isPrimitive(Symbol()); // true
isPrimitive([]); // false
isPrimitive(new String('Hello!')); // false
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isPromiseLike
Returns `true` if an object looks like a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), `false` otherwise.

File diff suppressed because one or more lines are too long