Travis build: 748 [ci skip]
This commit is contained in:
32
README.md
32
README.md
@ -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
Reference in New Issue
Block a user