|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
485 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var callBound = require('call-bound');
|
|---|
| 4 |
|
|---|
| 5 | var $PromiseThen = callBound('Promise.prototype.then', true);
|
|---|
| 6 |
|
|---|
| 7 | var isObject = require('es-object-atoms/isObject');
|
|---|
| 8 |
|
|---|
| 9 | // https://262.ecma-international.org/6.0/#sec-ispromise
|
|---|
| 10 |
|
|---|
| 11 | module.exports = function IsPromise(x) {
|
|---|
| 12 | if (!isObject(x)) {
|
|---|
| 13 | return false;
|
|---|
| 14 | }
|
|---|
| 15 | if (!$PromiseThen) { // Promises are not supported
|
|---|
| 16 | return false;
|
|---|
| 17 | }
|
|---|
| 18 | try {
|
|---|
| 19 | $PromiseThen(x); // throws if not a promise
|
|---|
| 20 | } catch (e) {
|
|---|
| 21 | return false;
|
|---|
| 22 | }
|
|---|
| 23 | return true;
|
|---|
| 24 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.