(obj, context)
| 8786 | var isObject = util.isObject; |
| 8787 | |
| 8788 | function tryConvertToPromise(obj, context) { |
| 8789 | if (isObject(obj)) { |
| 8790 | if (obj instanceof Promise) return obj; |
| 8791 | var then = getThen(obj); |
| 8792 | if (then === errorObj) { |
| 8793 | if (context) context._pushContext(); |
| 8794 | var ret = Promise.reject(then.e); |
| 8795 | if (context) context._popContext(); |
| 8796 | return ret; |
| 8797 | } else if (typeof then === "function") { |
| 8798 | if (isAnyBluebirdPromise(obj)) { |
| 8799 | var ret = new Promise(INTERNAL); |
| 8800 | obj._then( |
| 8801 | ret._fulfill, |
| 8802 | ret._reject, |
| 8803 | undefined, |
| 8804 | ret, |
| 8805 | null |
| 8806 | ); |
| 8807 | return ret; |
| 8808 | } |
| 8809 | return doThenable(obj, then, context); |
| 8810 | } |
| 8811 | } |
| 8812 | return obj; |
| 8813 | } |
| 8814 | |
| 8815 | function doGetThen(obj) { |
| 8816 | return obj.then; |
no test coverage detected