Travis build: 734 [ci skip]

This commit is contained in:
Travis CI
2017-12-31 13:54:58 +00:00
parent c86cceed14
commit c46e247cf8
3 changed files with 52 additions and 3 deletions

View File

@ -250,6 +250,7 @@
* [`isFunction`](#isfunction)
* [`isNull`](#isnull)
* [`isNumber`](#isnumber)
* [`isPromiseLike`](#ispromiselike)
* [`isString`](#isstring)
* [`isSymbol`](#issymbol)
* [`isValidJSON`](#isvalidjson)
@ -4196,6 +4197,37 @@ isNumber(1); // true
<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.
Check if the object is not `null`, its `typeof` matches either `object` or `function` and if it has a `.then` property, which is also a `function`.
```js
const isPromiseLike = obj =>
obj !== null &&
(typeof obj === 'object' || typeof obj === 'function') &&
typeof obj.then === 'function';
```
<details>
<summary>Examples</summary>
```js
isPromiseLike({
then: function() {
return '';
}
}); // true
isPromiseLike(null); // false
isPromiseLike({}); // false
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isString
Checks if the given argument is a string.

File diff suppressed because one or more lines are too long

View File

@ -6,11 +6,17 @@ Check if the object is not `null`, its `typeof` matches either `object` or `func
```js
const isPromiseLike = obj =>
obj !== null && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
obj !== null &&
(typeof obj === 'object' || typeof obj === 'function') &&
typeof obj.then === 'function';
```
```js
isPromiseLike({then:function () {return ''}}); // true
isPromiseLike({
then: function() {
return '';
}
}); // true
isPromiseLike(null); // false
isPromiseLike({}); // false
```