src/yaku.aplus.js
function settleWithX (p, x) {
        // 2.3.1
        if (x === p && x) {
            settlePromise(p, $rejected, new TypeError('promise_circular_chain'));
            return;
        }

        // 2.3.2
        // 2.3.3
        var xthen, type = typeof x;
        if (x !== null && (type === 'function' || type === 'object')) {
            try {
                // 2.3.2.1
                xthen = x.then;
            } catch (err) {
                // 2.3.3.2
                settlePromise(p, $rejected, err);
                return;
            }
            if (typeof xthen === '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, new TypeError('promise_circular_chain'));
            return;
        }

        // 2.3.2
        // 2.3.3
        var xthen, type = typeof x;
        if (x !== null && (type === 'function' || type === 'object')) {
            try {
                // 2.3.2.1
                xthen = x.then;
            } catch (err) {
                // 2.3.3.2
                settlePromise(p, $rejected, err);
                return;
            }
            if (typeof xthen === '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 , new TypeError ( 'promise_circular_chain' ) ) ; return ; } // 2.3.2 // 2.3.3 var xthen , type = typeof x ; if ( x !== null && ( type === 'function' || type === 'object' ) ) { try { // 2.3.2.1 xthen = x . then ; } catch ( err ) { // 2.3.3.2 settlePromise ( p , $rejected , err ) ; return ; } if ( typeof xthen === '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 primise 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 primise with value x . The x can also be a thenable .