src/yaku.core.js
function settleWithX (p, x) {
        // 2.3.1
        if (x === p && x) {
            settlePromise(p, $rejected, genTypeError($promiseCircularChain));
            return p;
        }

        // 2.3.2
        // 2.3.3
        if (x !== $null && (isFunction(x) || isObject(x))) {
            // 2.3.2.1
            var xthen = genTryCatcher(getThen)(x);

            if (xthen === $tryErr) {
                // 2.3.3.2
                settlePromise(p, $rejected, xthen.e);
                return p;
            }

            if (isFunction(xthen)) {
                // Fix https://bugs.chromium.org/p/v8/issues/detail?id=4162
                if (isYaku(x))
                    settleXthen(p, x, xthen);
                else
                    nextTick(function () {
                        settleXthen(p, x, xthen);
                    });
            } else
                // 2.3.3.4
                settlePromise(p, $resolved, x);
        } else
            // 2.3.4
            settlePromise(p, $resolved, x);

        return p;
    }
function settleWithX (p, x) {
        // 2.3.1
        if (x === p && x) {
            settlePromise(p, $rejected, genTypeError($promiseCircularChain));
            return p;
        }

        // 2.3.2
        // 2.3.3
        if (x !== $null && (isFunction(x) || isObject(x))) {
            // 2.3.2.1
            var xthen = genTryCatcher(getThen)(x);

            if (xthen === $tryErr) {
                // 2.3.3.2
                settlePromise(p, $rejected, xthen.e);
                return p;
            }

            if (isFunction(xthen)) {
                // Fix https://bugs.chromium.org/p/v8/issues/detail?id=4162
                if (isYaku(x))
                    settleXthen(p, x, xthen);
                else
                    nextTick(function () {
                        settleXthen(p, x, xthen);
                    });
            } else
                // 2.3.3.4
                settlePromise(p, $resolved, x);
        } else
            // 2.3.4
            settlePromise(p, $resolved, x);

        return p;
    }
function settleWithX ( p , x ) { // 2.3.1 if ( x === p && x ) { settlePromise ( p , $rejected , genTypeError ( $promiseCircularChain ) ) ; return p ; } // 2.3.2 // 2.3.3 if ( x !== $null && ( isFunction ( x ) || isObject ( x ) ) ) { // 2.3.2.1 var xthen = genTryCatcher ( getThen ) ( x ) ; if ( xthen === $tryErr ) { // 2.3.3.2 settlePromise ( p , $rejected , xthen . e ) ; return p ; } if ( isFunction ( xthen ) ) { // Fix https://bugs.chromium.org/p/v8/issues/detail?id=4162 if ( isYaku ( x ) ) settleXthen ( p , x , xthen ) ; else nextTick ( function ( ) { settleXthen ( p , x , xthen ) ; } ) ; } else // 2.3.3.4 settlePromise ( p , $resolved , x ) ; } else // 2.3.4 settlePromise ( p , $resolved , x ) ; return p ; }
Resolve or reject promise with value x. The x can also be a thenable.
@private
@param {Yaku} p
@param {Any | Thenable} x A normal value or a thenable.
Resolve or reject promise with value x . The x can also be a thenable .