MCPcopy Create free account
hub / github.com/play-co/devkit / tryConvertToPromise

Function tryConvertToPromise

src/web/util/bluebird.js:3452–3479  ·  view source on GitHub ↗
(obj, context)

Source from the content-addressed store, hash-verified

3450var isObject = util.isObject;
3451
3452function 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
3481function getThen(obj) {
3482 return obj.then;

Callers 4

bluebird.jsFile · 0.85
finallyHandlerFunction · 0.85
tapHandlerFunction · 0.85
ReductionPromiseArrayFunction · 0.85

Calls 3

isObjectFunction · 0.85
isAnyBluebirdPromiseFunction · 0.85
doThenableFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…