-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(from): objects that are thennable that happen to have a subscribe…
… method will no longer error.
- Loading branch information
Showing
2 changed files
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { isFunction } from "./isFunction"; | ||
|
||
/** | ||
* Tests to see if the object is an ES2015 (ES6) Promise | ||
* @see {@link https://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects} | ||
* Tests to see if the object is "thennable". | ||
* @param value the object to test | ||
*/ | ||
export function isPromise(value: any): value is PromiseLike<any> { | ||
return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function'; | ||
return isFunction(value?.then); | ||
} |