(obj, context)
| 3450 | var isObject = util.isObject; |
| 3451 | |
| 3452 | function tryConvertToPromise(obj, context) { |
| 3453 | if (isObject(obj)) { |
| 3454 | if (obj instanceof Promise) { |
| 3455 | return obj; |
| 3456 | } |
| 3457 | else if (isAnyBluebirdPromise(obj)) { |
| 3458 | var ret = new Promise(INTERNAL); |
| 3459 | obj._then( |
| 3460 | ret._fulfillUnchecked, |
| 3461 | ret._rejectUncheckedCheckError, |
| 3462 | ret._progressUnchecked, |
| 3463 | ret, |
| 3464 | null |
| 3465 | ); |
| 3466 | return ret; |
| 3467 | } |
| 3468 | var then = util.tryCatch(getThen)(obj); |
| 3469 | if (then === errorObj) { |
| 3470 | if (context) context._pushContext(); |
| 3471 | var ret = Promise.reject(then.e); |
| 3472 | if (context) context._popContext(); |
| 3473 | return ret; |
| 3474 | } else if (typeof then === "function") { |
| 3475 | return doThenable(obj, then, context); |
| 3476 | } |
| 3477 | } |
| 3478 | return obj; |
| 3479 | } |
| 3480 | |
| 3481 | function getThen(obj) { |
| 3482 | return obj.then; |
no test coverage detected
searching dependent graphs…